3 Replies Latest reply on Aug 19, 2008 4:27 PM by tonyukuk

    database problem

    tonyukuk
      Every time I restart the application, everything in my database is erased. I got these errors from jboss server. do you have any idea about this problem

      15:09:13,092 INFO  [SchemaExport] Running hbm2ddl schema export
      15:09:13,092 INFO  [SchemaExport] exporting generated schema to database
      15:09:22,701 INFO  [Ejb3Configuration] [PersistenceUnit: dfs] no META-INF/orm.xml found
        • 1. Re: database problem
          sjmenden
          Per Hibernate docs:

          hibernate.hbm2ddl.auto      Automatically validate or export schema DDL to the database when the SessionFactory is created. With create-drop, the database schema will be dropped when the SessionFactory is closed explicitly.

          eg. validate | update | create | create-drop


          so in your persistence.xml you want to comment out:

          <property name="hibernate.hbm2ddl.auto" value="create-drop"/>

          or set it to create to generate your ddl for the first time then comment it out.  Of course, in production you never want a create-drop policy, but during development it is the best idea to allow quick changes to your Entities/code.


          • 2. Re: database problem
            sjmenden
            One addition to what I was previously saying, in development, you'll typically combine <property name="hibernate.hbm2ddl.auto" value="create-drop"/> with import statements in your import-dev.sql which will create-drop your ddl every time you redeploy and repopulate the database with test data for you to click through and manually test out new code.
            • 3. Re: database problem
              tonyukuk

              it worked. thank you