-->
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: <version> tag and null value
PostPosted: Fri Oct 15, 2010 1:06 pm 
Newbie

Joined: Wed Oct 13, 2010 11:19 am
Posts: 7
I have a version tag:
<version name="civUpdateDt" type="dbtimestamp">
<column name="CIV_UPDATE_DT" not-null="false" default="0"/>
</version>

Everything works fine except on the first update because the column CIV_UPDATE_DT is null. Hibernate throws the Stale Object State Exception even when I pass in a null value for that column. Is there a way around this?

thanks,
Peter


Top
 Profile  
 
 Post subject: Re: <version> tag and null value
PostPosted: Fri Oct 15, 2010 3:07 pm 
Newbie

Joined: Wed Oct 13, 2010 11:19 am
Posts: 7
I've figured out why this is happening by looking at Hibernates SQL:

update EID.CIVILIANS set CIV_UPDATE_BY = 'John', CIV_UPDATE_DT=?, CIV_FNAME=? where CIV_ID=? and CIV_UPDATE_DT=?

if the CIV_UPDATE_DT is null then it should be:

CIV_UPDATE_DT is ?
not
CIV_UPDATE_DT=?

The database updates 0 rows because of this and Hibernate throws a row mismatch exception, which gets converted to a StaleObjectStateException. Is there any fix for this? Putting CIV_UPDATE_DT in the where clause doesn't seem necessary if Hibernate has already done the check.


Top
 Profile  
 
 Post subject: Re: <version> tag and null value
PostPosted: Wed Nov 03, 2010 1:24 pm 
Newbie

Joined: Wed Oct 13, 2010 11:19 am
Posts: 7
Just to answer this, Hibernate really doesn't support null values for the version fields. Most of the time this shouldn't be a problem, we just have a quirky database that has two timestamp fields, one for insert and one for update.


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.