-->
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.  [ 2 posts ] 
Author Message
 Post subject: Default column values
PostPosted: Thu Jul 13, 2006 7:07 pm 
Newbie

Joined: Wed Sep 28, 2005 9:40 am
Posts: 3
Hello,

Is there a way to add default values to columns so that when the tables are updated with new properties when I restart my web app, they get added with those defaults ?

When I add new properties (columns) to exisiting tables that have data in them, the new columns will always be created as nullable and with NULL values (MySQL 5.0), even if I use @Column (nullable = false)


Thanks,
Jorge


Top
 Profile  
 
 Post subject: Default column values
PostPosted: Sat Jul 15, 2006 4:31 pm 
Newbie

Joined: Wed Sep 28, 2005 9:40 am
Posts: 3
Well, I finally found this and it works, but I'm not sure using it will be portable across databases:

Code:
@Column(columnDefinition="int(11) not null default 5")
public int getNumItems() {
  return numItems;
}



Jorge


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