-->
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 + Oracle problem
PostPosted: Wed Feb 27, 2008 5:22 am 
Newbie

Joined: Wed Feb 27, 2008 5:13 am
Posts: 1
Hi all,

I'm having a problem trying to make my application work with a combination of hibernate and Oracle database.

My Spring configuration indicates:

The value of the property "hibernate.hbm2ddl.auto" is "create".

And the result is that the database is recreated on each server startup, which results with the deletion of all data in the database which was there prior to the startup.

If I choose the value of "hibernate.hbm2ddl.auto" to be "update" then the database is not created at all on startup even if it doesn't exist.
The same behavior happens if I don't use the hibernate.hbm2ddl.auto flag at all.

Can someone help?
All I want is that the database will be created if it doesnt exist, and afterwards the data will not be deleted after startup.

By the way if my database is MySQL and I don't use the hibernate.hbm2ddl.auto flag at all then the behavior is fine: the DB is created only if doesn't exist and data isn't deleted. The wrong behavior happens only if my DB is Oracle.

Thanks,
Miro.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 27, 2008 11:39 am 
Senior
Senior

Joined: Fri Jun 01, 2007 12:41 pm
Posts: 121
Quote:
Can someone help?
All I want is that the database will be created if it doesnt exist, and afterwards the data will not be deleted after startup.


hibernate.hbm2ddl.auto has only 3 values.
## auto schema export
#hibernate.hbm2ddl.auto create-drop
#hibernate.hbm2ddl.auto create
#hibernate.hbm2ddl.auto update
#hibernate.hbm2ddl.auto validate

The best you can do is export the database first time before running the application using ANT task or using SchemaExport while building session factory.

You can SchemaExport with ANT tasks to validate and update database.

It is always advisable to turn off hbm2ddl.auto property in Production configuration. For Dev purpose, you can use either 'validate' or 'update'.


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.