-->
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: Calculated property (by formula) not updated on insert
PostPosted: Mon Jul 09, 2007 9:09 am 
Newbie

Joined: Thu May 31, 2007 4:31 am
Posts: 5
Hi,
I have mapping like:
<property name="VpId" formula="(select emsJob.VP_ID from EMS_JOB as emsJob where emsJob.JOB_ID = JOB_ID)" />

When class loaded I receive right value in calculated property.
Problem is when class added to DB (session.Save(obj)). The proprty remaining empty.

Thanks,
Dima


Top
 Profile  
 
 Post subject: Re: Calculated property (by formula) not updated on insert
PostPosted: Tue Nov 01, 2011 2:37 pm 
Newbie

Joined: Wed Dec 08, 2010 3:49 pm
Posts: 2
In case anyone else runs upon this thread while trying to fix the same issue --

Adding the following annotation to the calculated property in the entity class will tell Hibernate to generate this value (run the formula) when a row is inserted. This will prevent the value from being null after an insert.

@org.hibernate.annotations.Generated(GenerationTime.INSERT)


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.