-->
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: HOw to set default property value in hibernate 3.0
PostPosted: Fri Dec 23, 2005 12:48 pm 
Newbie

Joined: Fri Dec 23, 2005 9:12 am
Posts: 1
Hi
I am trying to set default property value of a column using hibernate. WE are generating our database tables using the hbm files. So I want to have default values set for some columns in the property element of the hbm file.

Kindly if you all can show me the way of setting the default value in the property element.

Tried the default element within the property element , but didnt helped. I am using Hibernate 3.0.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 26, 2005 1:13 am 
Expert
Expert

Joined: Thu May 26, 2005 9:19 am
Posts: 262
Location: Oak Creek, WI
Hi,

Did you use something like this?

Source Hibernate Doc.
The default attribute lets you specify a default value for a column (you should assign the same value to the mapped property before saving a new instance of the mapped class).

<property name="credits" type="integer" insert="false">

<column name="credits" default="10"/>

</property>

_________________
RamnathN
Senior Software Engineer
http://www.linkedin.com/in/ramnathn
Don't forget to rate.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 26, 2005 10:20 am 
Regular
Regular

Joined: Wed Dec 21, 2005 6:57 pm
Posts: 70
Not sure I understand your issue.

Your DB should match your objects, so think about objects first and how to map them second. If the object should have a particular value in a field, add it to the object's configuration, and let it get persisted normally.


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.