Announcement Announcement Module
Collapse
No announcement yet.
Database Records After Logout Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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

    Comment


    • #3
      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, 05:57 AM.

      Comment


      • #4
        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

        Comment


        • #5
          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.

          Comment

          Working...
          X