-->
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.  [ 1 post ] 
Author Message
 Post subject: setting a default value for a not null propoerty
PostPosted: Fri Jul 27, 2007 10:16 am 
Newbie

Joined: Thu Jul 28, 2005 8:27 am
Posts: 7
Hi,
i have this not null field 'zip' in a table 'address' and its default value is set to '78548'. But when i try to save a new object for address with zip set to null hibernate gives me an error that the 'zip' field is not null and i should give it some value. Now, the question is should'nt the hibernate be smart enough to pick up the default value for that column itself? If no then how to set a default value for a not null propoerty in hibernate?
I tried the following thing in my Address.hbm.xml but it didnt work either:

<property
name="zip"
type="java.lang.String"
not-null="true"
>
<column name="zip" default="78548"/>
</property>

any help would be great.
b.t.w. Im using Hibernate 3.1 with MySql 5


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.