-->
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: Map to different versions of a table
PostPosted: Thu Sep 23, 2010 6:55 pm 
Newbie

Joined: Thu Sep 23, 2010 6:44 pm
Posts: 2
Hello there.

I need to add a new field to a database table that is already in production.
On top of that, my project is only going live a year from now. In the meantime, there will be other projects being released, and we are using XML files to define "switches" where we can turn some functionalities on and off.

The bottom line is: I cannot just add the column to the database and to the mapping class, since it will break the projects that will be released before mine.

What I was thinking is to have different mappings, one for the current table and another one to map the new table (that includes the new column).

Is this an easy thing to do with Hibernate? I mean, how will I create my classes and my mappings? Just extending my current class to have the new column wouldn't work, since I want to keep the storing mechanism the same (to avoid duplication.)

I've done some research but couldn't find solutions for this situations (probably because I'm not searching the right terms, since I don't have any experience with Hibernate.)

Any help will be greatly appreciated.

Thanks a lot!


Top
 Profile  
 
 Post subject: Re: Map to different versions of a table
PostPosted: Sat Sep 25, 2010 1:56 am 
Newbie

Joined: Wed Jun 18, 2008 9:17 am
Posts: 12
1 year is too long and many things can change.

Best approach will be to work on a branch version of your code repository and merge your code with the main trunk and update the database when you ready to deploy to production. Obviously you will do all this in UAT/integration area before to check all the pieces are working correctly.

However, if you can this new column to database and update the map this column as @Transient which will tell hibernate to not persist/update this column.

When you ready to deploy your changes, take out the @Transient.


having said that, my personal opinion is not to add things to production when they are not needed. Working in a branch and keeping your branch updated with the latest trunk/head version will be my preferred option.


Top
 Profile  
 
 Post subject: Re: Map to different versions of a table
PostPosted: Sun Sep 26, 2010 7:14 pm 
Newbie

Joined: Thu Sep 23, 2010 6:44 pm
Posts: 2
Oh sorry. I meant one month from now.

We're using trunk-based development for 2 years now and it's been amazing. We have a lot of people working on the same codebase and merging things around from several different branches is out of question.

Basically what I need is: depending on the value of one property, I will need to save and retrieve that column from the database. Is there another functionality that provides this @Transient behavior? I will obviously not be able to apply or not the annotation based on a property.

Thanks!


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.