Results 1 to 5 of 5

Thread: Database Records After Logout

  1. #1
    Join Date
    Mar 2010
    Posts
    3

    Default Database Records After Logout

    Hi,

    First, I'd like to mention that I'm a newbie to spring roo and hibernate as well.

    Second, I followed the basic tutorial for spring on the blog and everything is fine and working great. But, I have tried using MYSQL instead. I works fine as well except that after entering some data and then logging out, the data gets lost.

    Do you have any idea why this happens? Is this intentional?

    Thank you

  2. #2
    Join Date
    Aug 2004
    Location
    Sydney, Australia
    Posts
    2,768

    Default

    From http://static.springsource.org/sprin...inning-step-1:

    When you are ready to test or install your application in a production setting, the persistence setup command can be repeated. This allows you to nominate a different database, or even ORM. Roo offers TAB completion for production databases including Postgres, MySQL, Microsoft SQL Server, Oracle, DB2, Sybase, H2, Hypersonic and more. Another important step is to edit the SRC_MAIN_RESOURCES/META-INF/persistence.xml file and modify your JPA provider's DDL (schema management) configuration setting so it preserves the database between restarts of your application. To help you with this, Roo automatically lists the valid settings for your JPA provider as a comment in that file. Note that by default your JPA provider will drop all database tables each time it reloads. As such you'll certainly want to change this setting.
    HTH
    Ben
    Ben Alex
    Project Founder, Spring UAA, Spring Roo and Spring Security

  3. #3
    Join Date
    Mar 2010
    Posts
    3

    Default

    Hi Ben,

    Thanks for the quick reply. I had lots of things to do so I couldn't check your solution.

    I have tried changing the
    Code:
    <property name="hibernate.hbm2ddl.auto" value="create"/>
    to
    Code:
    <property name="hibernate.hbm2ddl.auto" value="update"/>
    and it works fine, i.e data is preserved between restarts

    But I couldn't find the comments in the persistence.xml file.
    To help you with this, Roo automatically lists the valid settings for your JPA provider as a comment in that file.
    Am I missing something?
    Last edited by araouf; Mar 13th, 2010 at 05:57 AM.

  4. #4
    Join Date
    Mar 2008
    Location
    Sydney, AU
    Posts
    974

    Default

    If you look into persistence.xml:

    Code:
        <persistence-unit name="persistenceUnit" transaction-type="RESOURCE_LOCAL">
            <provider>org.hibernate.ejb.HibernatePersistence</provider>
            <properties>
                <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>
                <!--value='create' to build a new database on each run; value='update' to modify an existing database; value='create-drop' means the same as 'create' but also drops tables when Hibernate closes; value='validate' makes no changes to the database-->
                <property name="hibernate.hbm2ddl.auto" value="create"/>
                <property name="hibernate.ejb.naming_strategy" value="org.hibernate.cfg.ImprovedNamingStrategy"/>
            </properties>
        </persistence-unit>
    .. you should see the comment that Roo includes into the configuration...

    -Stefan
    Stefan Schmidt
    Software Engineer, Spring Roo
    SpringSource - a division of VMware
    twitter @schmidtstefan

  5. #5
    Join Date
    Mar 2010
    Posts
    3

    Default

    Hi Stefan,

    Although my problem is now fixed, I'd like to note that I didn't find the comment. I even created a new project from scratch to test this issue but it seems there is no comment added to the file. I am using 1.0.1.RELEASE [rev 601].

    Thank you.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •