Hibernate version: 3.2.0 CR3
I am using Hibernate in GlassFish(
http://glassfish.dev.java.net) and have turned on
automatic table generation feature by specifying the following propery in persistence.xml:
Code:
<property name="hibernate.hbm2ddl.auto" value="create-drop"/>
I am observing that when app server calls
PersistenceProvider.createContainerEntityManagerFactory(PersistenceUnitInfo...), Hibernate creates table and when
EntityManagerFactory.close() is called, tables are dropped. Since the app server is making these calls when it starts and stops respectively, I see that tables are getting created everytime the server starts and they are dropped when the server stops. Is this how this feature supposed to work in application server? Does it behave this way in JBoss?
That's a bit different from the way automatic table generation (
http://blogs.sun.com/roller/page/java2dbInGlassFish) feature works in GlassFish. In GlassFish we have a similar property for our default persistence provider(TopLink Essentials). It creates tables when application is deployed in GlassFish and drops the tables when the app is undeployed. In between, when the app server is stopped or started, we don't drop tables. We have written some code in GlassFish to achieve this functionality.
Any suggestion as to how to achive this kind of behavior while using Hibernate in GlassFish?
Is there a way to configure Hibernate persistence provider so that it writes out the DDLs to a stream instead of executing them?
Thanks,
Sahoo