-->
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: Changing value of a property at insertion time
PostPosted: Tue Sep 30, 2008 7:15 am 
Newbie

Joined: Tue Sep 30, 2008 6:51 am
Posts: 3
Location: India
Hi All,

I have a POJO which is having an int (primitive) field. I have a specific requirement that whenever no value is passed in this fields means whenever this field defaults to zero, a null value should be stored in the corresponding nullable field of the database instead of the default value of primitive int. Can this be done using hibernate mapping?

I can not do any change in my POJO class, I have to do this on database level (i.e. Hibernate) only.

_________________
Regards,
Aryan


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 01, 2008 6:51 am 
Beginner
Beginner

Joined: Thu May 17, 2007 9:56 am
Posts: 21
Location: India
Hi,
Can you attach your hbm mapping file?

_________________
Kuzhali


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 01, 2008 7:06 am 
Newbie

Joined: Tue Sep 30, 2008 6:51 am
Posts: 3
Location: India
We can just take an example. In the following mapping if the col1 filed is of int type and its an optional field, Hibernate will set its default value as an integer's default value, i.e. 0. But in database I want to set it as NULL. How can I achieve this specific requirement?

Code:
<hibernate-mapping>
   <class name="com.ibm.wdp.bss.party.entity.AddressBean"
      table="tab1">
      <id name="id" type="long" column="Id">
         <generator class="increment" />
      </id>
      
      <property name="col1" type="int" column="COL"/>
      
   </class>
</hibernate-mapping>

_________________
Regards,
Aryan


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.