-->
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.  [ 8 posts ] 
Author Message
 Post subject: Help on Configuration property: hibernate.hbm2ddl.auto
PostPosted: Wed Jun 20, 2007 2:13 am 
Newbie

Joined: Wed Jun 20, 2007 2:02 am
Posts: 4
Hi,

I'm totally new to Hibernate. My project requires me to work on Hibernate. So I'm trying to run a sample application.

The issue is since I'm connecting to production database, I want to make sure that I don't end up modifying the database.

Came across
Quote:
hibernate.hbm2ddl.auto
which depending on the values [create, create-drop, update etc.] would drop and create the databse schema.

Please advice me on what value to be assigned o this configuration property so that I just read some records from the database without altering the database schema.

Also whats the default value for this property?

Thanks in advance
sara.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 20, 2007 4:13 am 
Senior
Senior

Joined: Tue Jun 12, 2007 4:49 pm
Posts: 127
Location: India
hibernate.hbm2ddl.auto has three options create, create-update and validate.

Create will drop and create all tables.
create-update will only modify the tables which can be modified and ignore the rest.
Validate will only validate the schema and throw exception if there are any mismatches. Validation is very very strict and generally conflicts with the generated schema itself :-s.

Default option is create-update

*Please do rate if it helps*

Regards,
Jitendra


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 20, 2007 4:44 am 
Newbie

Joined: Wed Jun 20, 2007 2:02 am
Posts: 4
Thanks for the reply Jiten.

So can I be sure that if I use 'validate' as value for 'hibernate.hbm2ddl.auto', it will not affect the database at all?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 20, 2007 6:44 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Just don't put it in your configuration file and NOTHING will happen. There is no default.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject: Re:
PostPosted: Wed Jun 20, 2007 6:51 am 
Senior
Senior

Joined: Tue Jun 12, 2007 4:49 pm
Posts: 127
Location: India
Hi Christian,

Has this been changed in recent releases? I remember reading that default was create-update.

We had a big issue in our project because of it, if it has been solved in any recent release, we would like to upgrade to that.

Regards,
Jitendra


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 20, 2007 6:55 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
There is NO DEFAULT. If you don't put it in your configuration file, nothing will happen.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 20, 2007 7:08 am 
Newbie

Joined: Wed Jun 20, 2007 2:02 am
Posts: 4
Thanks Christian.

I got confused seeing the following thread.

http://jboss.com/?module=bb&op=viewtopic&t=69683

Regards
sara


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 20, 2007 8:47 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
This has apparently been a wrong out-of-the-box setting in the EJB3 RC2 release, which is now 2 years old and has been superseded by almost 10 other releases.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 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.