-->
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: Update database schema without delete remaining data
PostPosted: Thu Jan 22, 2004 12:12 am 
Beginner
Beginner

Joined: Thu Jan 08, 2004 4:40 am
Posts: 48
Location: Bangkok, Thailand
Dear all
My case is for example I have got one table called MEMBERS that has detail like this:


MEMBERS(memberId, name, surname);


and in this table has contained 150 records already. If oneday my customer would like to add more information to this TABLE, email, so I have to change my schema in HB mapping.
How can I tell hibernate to change DATABASE schema in my table without delete all my data in MEMBERS table
Thanks

_________________
<name>arin</name>
<at>netplus software</at>


Top
 Profile  
 
 Post subject: not a problem..
PostPosted: Thu Jan 22, 2004 4:56 am 
Beginner
Beginner

Joined: Thu Oct 02, 2003 5:06 am
Posts: 26
Location: Budapest, Hungary
I would assume you would have to start with the database. Most major databases will allow you to add a column, or even remove a column from a table (unless part of an index, in which case, first drop the index etc) without deleting the data in the table.

All you need to do is (e.g for postrges)

Code:
ALTER TABLE members ADD COLUMN email VARCHAR(30);


and then add the email field to the hibernate mapping... (and of course use it wherever you want to in your application)
Cheers
Ati


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 23, 2004 3:05 am 
Beginner
Beginner

Joined: Thu Jan 08, 2004 4:40 am
Posts: 48
Location: Bangkok, Thailand
Thanks Guys
That's my false, I'm using Xdoclet and Maven and I forgot to disable auto-create table in database. That's a reason why everytime I change mapping file my data will be removed.

Cheers

_________________
<name>arin</name>
<at>netplus software</at>


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.