-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: How to control table generation inside GlassFish
PostPosted: Fri Jul 28, 2006 12:23 am 
Newbie

Joined: Wed Mar 29, 2006 3:47 pm
Posts: 17
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


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 28, 2006 1:44 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
if you don't want the tables dropped may i suggest you don't use create-*drop* ? :)

just use create

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 28, 2006 1:50 am 
Newbie

Joined: Wed Mar 29, 2006 3:47 pm
Posts: 17
max wrote:
if you don't want the tables dropped may i suggest you don't use create-*drop* ? :)

just use create


That does not help because I want the tables to be dropped when the application is undeployed.

Thanks for responding,
Sahoo


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 28, 2006 2:06 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
Then run schemaexport explicitly.

stupid question: How does JPA get access to info on when the overarching applicaiton is undeployed ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.