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.  [ 2 posts ] 
Author Message
 Post subject: hibernate.hbm2ddl.auto create OR create manually
PostPosted: Fri Jul 02, 2010 5:52 am 
Newbie

Joined: Fri Jul 02, 2010 5:10 am
Posts: 2
This setting works fine if the database is empty, but if the tables are already created, i get error messages in the logfile.
Now the code still works fine so no problem, but getting [ERROR] written to the logfile everytime the programm is run is not something I want.

I would find it tedious to have to change the value in persistence.xml every time when i need either create or validate functionality. So maybe you can tell me if it is possible to manually initiate validation/creation.
OR you can tell me i can leave hbm2ddl.auto perpetually to create, because it causes no harm and there is a way to suppress those error messages without suppressing all hibernate related errors.


Also the information for the behaviour of create is not clear regarding the dropping of tables when the database is not empty, I'll quote your documentation:

Quote:
hibernate.hbm2ddl.auto Automatically validates or exports 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.

e.g. validate | update | create | create-drop


some sources reported a deleting of tables, my experience is it does not delete the tables prior to creating, it does give me ERROR messages though as stated above.

Thanks already!


Top
 Profile  
 
 Post subject: Re: hibernate.hbm2ddl.auto create OR create manually
PostPosted: Fri Jul 02, 2010 8:31 pm 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
you could try update, but I really wonder if you would trust that on production databases, the only value I would ever recommend is "validate".

The class SchemaExport can be used to programmatically control DDL statements; which is callable from command line too as a tool; or there's an ANT task too, so you can automate this kind of jobs. Finally, people often play with "profiles" and deployment targets, using filtering (Ant or Maven) of the persistence.xml to insert the appropriate tokens.

Quote:
some sources reported a deleting of tables, my experience is it does not delete the tables prior to creating,

isn't that exactly what the quoted documentation is stating? what's confusing?

_________________
Sanne
http://in.relation.to/


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