-->
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.  [ 7 posts ] 
Author Message
 Post subject: How can I upgrade application which uses Hibernate
PostPosted: Tue Dec 07, 2004 7:00 pm 
Beginner
Beginner

Joined: Fri Mar 12, 2004 5:18 pm
Posts: 44
Hi,

If I have an application with uses Hibernate as the persistence layer, what is the best practice to upgrade my application?

For example, I have a class called "User" and its has an attribute "String username". I use hibernate to make this class persistence.

I deploy this version of application and have database populate with data.

But what if in future, I need to add a new attribute "password" in the User class. How can I /or hibernate will still work with the database that I created for the older version? Will hibernate smart enough to add a new column for the new attribute in my User class ?


Hibernate version:
2.1.7
Mapping documents:
N/A
Code between sessionFactory.openSession() and session.close():
N/A
Full stack trace of any exception that occurs:
N/A
Name and version of the database you are using:
MySQL
The generated SQL (show_sql=true):
N/A
Debug level Hibernate log excerpt:
N/A


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 08, 2004 8:12 am 
Expert
Expert

Joined: Tue Dec 07, 2004 6:57 am
Posts: 285
Location: Nürnberg, Germany
I doubt that. You will have to upgrade the database yourself, but Hibernate has some tools with which you can export the DDL statements for the creation of your database.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 08, 2004 10:12 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Guys, there is a whole chapter about it in the documentation.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 11, 2005 5:59 pm 
Beginner
Beginner

Joined: Fri Mar 12, 2004 5:18 pm
Posts: 44
Thanks for the answer.

Could you please tell me which chapter in hibernate documentation talks about it? I have the "hibernate in action" book too, I can't find a chapter which talks about upgrading hibernate application.

Thank you.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Feb 12, 2005 6:17 am 
Beginner
Beginner

Joined: Thu May 13, 2004 5:51 am
Posts: 28
sy_cheung2 wrote:
Thanks for the answer.

Could you please tell me which chapter in hibernate documentation talks about it?


Chapter 15. ToolSet Guide (15.1: Schema Generation )
Read through 15.1.5

--
Megha


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 14, 2005 5:40 pm 
Beginner
Beginner

Joined: Fri Mar 12, 2004 5:18 pm
Posts: 44
Thank you for your help.

Can you please tell me if/how hibernate supports back compatiblity?

For example, if I have new release of my application uses hibernate and that add/delete an attribute in my persistent object.

If I use Hibernate's tool to update my database scheme to add/remove an extra column in my table, will an older version of my application still works with this new table in my database?

And what will happen if I use my new application to read data from an un-updated database (missing column)?

Thank you.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 16, 2005 5:41 am 
Beginner
Beginner

Joined: Thu May 13, 2004 5:51 am
Posts: 28
sy_cheung2 wrote:

Can you please tell me if/how hibernate supports back compatiblity?

For example, if I have new release of my application uses hibernate and that add/delete an attribute in my persistent object.


SchemaUpgrade does not support dropping of columns :-( Its only an incremental add.

Quote:
If I use Hibernate's tool to update my database scheme to add/remove an extra column in my table, will an older version of my application still works with this new table in my database?
And what will happen if I use my new application to read data from an un-updated database (missing column)?


Umm sorry but how would a application against a un-matching schema work? What you would probably need to do before your application runs is to begin with an incremental update of your DB with hibernate. This will ensure missing columns your application accesses, are added.

Regarding the dropped columns, if my bean is matched with the hbm, and does not contain the column, my application does not care about it anymore. I am fine with this behaviour. But the DB fields will keep hanging around.. its your decision to make then.


--
Meg


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