-->
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 handle changed database schema
PostPosted: Thu Sep 21, 2006 9:52 am 
Newbie

Joined: Tue Sep 19, 2006 8:50 am
Posts: 7
Hi all,

does anyone have som good pointers on how to handle if, for example, you need to refactor your models, which leads to changed hbm-files and your database has data that must be migrated with the new scheme.

Can Hibernate do something to help out, is there any tools which simplifies the job or is this still manual work to do?

Greatfull for any help.

/Manny


Top
 Profile  
 
 Post subject:
PostPosted: Sun Sep 24, 2006 8:03 pm 
Newbie

Joined: Mon Aug 29, 2005 1:14 am
Posts: 10
middlegen will construct hbm.xml files from your database. You must specify many-to-many tables manually, but (if you have added the correct foreign keys to the database) it will deduce one-to-many joins correctly.

Since those hbm.xml files have extra markup, the hbm2java tool can create POJOs from the generated hbm.xml. The POJOS will contain xdoclet Hibernate markup so that hbm.xml can be generated from the POJOs.

Then you can diff the generated POJOs against your existing POJOs, and make necessary changes by hand.

If your table structures haven't changed, but have just been moved into different schema, it's even easier. Just add schema="new_schema" to your existing xdoclet markup or hbm.xml files.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 25, 2006 5:06 am 
Newbie

Joined: Tue Sep 19, 2006 8:50 am
Posts: 7
My problems are that I can't take the old data and import it into the new databse which is slightly different. I suspect that there are circular dependencys that psql fails on but I'm not sure.

As hibernate uses constraints I cannot import one table at the time and I'm now running out of ideas on how to get the data into the new database.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Oct 01, 2006 9:39 am 
Newbie

Joined: Tue Sep 19, 2006 8:50 am
Posts: 7
After some days I found that to me it took quite some effort to get things working. Hopefully I now have a way of updating databases with changed design so I don't have to go through this again. :)

I dumped the new database scheme and manually deleted all constraints which give me the oppurtunity, for example, to update a table at a time from the old databases tables. (The ones that was unchanged).

After my changes were made I updated the database with the new databse scheme that has all the constraints intact and after some tries I got things working.

/Manny


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.