2 Replies Latest reply on Apr 23, 2008 11:10 AM by chenww

    Automatic database schema management with JBoss & Hibernate

    chenww Newbie

      Buddies,

      I have an EJB jar that includes a persistence.xml. See it below. I try to deploy the jar and set "hibernate.hbm2ddl.auto=create". However this will cause the schema recreated everytime you restart the JBoss. If I set the property to update, the schema will not get created at the first time. Do you know how to let Hibernate automatically create schema just first time after product installed and loading EntityManagerFactory? I saw people are using ant task to do that but that is not an option as the products are deployed by customers. I guess I could use some Hibernate tools but I could not find in JBoss. I try to see if this needs could be satisfied by just configure something in the persistence.xml.

      Thanks & Regards


      <persistence-unit name="MyUnit">
      <jta-data-source>java:/MyDS</jta-data-source>

      <!-- property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/-->

      org.hibernate.transaction.JBossTransactionManagerLookup

      </persistence-unit>