-->
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.  [ 3 posts ] 
Author Message
 Post subject: Database synchronisation
PostPosted: Tue Feb 05, 2008 10:18 am 
Newbie

Joined: Tue Feb 05, 2008 10:13 am
Posts: 2
Hello,

I am wondering if it is possible to achieve a thing like this "natively" with Hibernate.

Let's say that I create a new project, create a database schema classes with Hibernate, and then run script "sync_database" that creates all the tables in the database.
That is doable as I have seen in the docs.

But, the next step. Then, I decide to change the schema, and add some fields to the classes or do other things.
So I change the classes, and then run the script again to delete old columns, add new and so on...

Is this possible natively? Or at all? I know that it is quite problematic with constraints.. but not impossible though to achieve that.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 05, 2008 10:30 am 
Regular
Regular

Joined: Mon Aug 20, 2007 6:47 am
Posts: 74
Location: UK
You can have hibernate create your schema each time you start your sessionFactory (i.e when you start your app) and drop it when it's finished.

use config property "hibernate.hbm2ddl.auto=create-drop" for this.

This will do what you wanted, but for obvious reasons your data will be lost between application restarts :S


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 05, 2008 10:59 am 
Newbie

Joined: Tue Feb 05, 2008 10:13 am
Posts: 2
So... It will not do what I have written about.
You did not understand the idea then ;)


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