-->
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: new field in class
PostPosted: Thu Jan 18, 2007 7:23 am 
Newbie

Joined: Thu Jan 04, 2007 6:09 am
Posts: 3
Is it any possibility to do this: add field in class - add column in tables? Without drop-and-create-tables, because this delete previous data.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 18, 2007 7:52 am 
Newbie

Joined: Thu Jan 04, 2007 6:09 am
Posts: 3
SOrry, hibernate.hbm2ddl.auto=update works great.
But i dont know how this doing in TopLink (via JPA).


Top
 Profile  
 
 Post subject: new field in class
PostPosted: Thu Jan 18, 2007 8:02 am 
Newbie

Joined: Wed Jan 10, 2007 3:07 pm
Posts: 8
Perhaps I'm misunderstanding your question (or else you are very much a newbie). To add a column to an existing table without destroying data is done with a simple SQL statement:

ALTER TABLE table_name ADD new_column_name data_type

For example, to add a VARCHAR(100) column called DESC to table FOO:

ALTER TABLE foo ADD desc varchar(100)

Depending on your database you might have different options (VARCHAR2 for Oracle; ADD COLUMN might be required). Check the documentation for your database.

Then just add the additional field to your class, and it's mapping, and restart the app.

If you're wanting to do it dynamically, without an app restart, I don't know how that could be done. But then again, I'm pretty much a Hibernate newbie myself.


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.