-->
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: Managed versioning not working
PostPosted: Wed Nov 01, 2006 8:33 pm 
Newbie

Joined: Wed Nov 01, 2006 8:17 pm
Posts: 2
Hi,
I am using Hibernate 3.0.5 with Spring (Version: 1.2.4)

I am setting the TCN (version field) of a VO to a number less than what it is in DB for that row. And I am expecting "StaleObjectStateException" while updating this VO.
But somehow Hibernate seems to be ignoring this new TCN, and is successfully updating the VO, and DB shows next TCN value for this VO.

Is there any setting to enable this option?
I might be doing something stupid. Please help. (look at lines in bold)
Here is code snippet:

********************************************************
Estimate estimate = docDao.findEstimateByEstimateDocId(estimateDocId);
if (estimate == null)
throw new DaoException(
"There is no estimate associated with the estimateDocId!");

EstimateXmlAnnotation xmlAnnotation = estimate
.getEstimateXmlAnnotation();
if (xmlAnnotation == null)
throw new DaoException(
"There is no annotation associated with the estimate!");

xmlAnnotation.setXmlData(xmlData); // input from client
xmlAnnotation.setUpdatedBy(updatedBy); //inputs from client
xmlAnnotation.setUpdatedDate(new Date());
xmlAnnotation.setCoCd(companyCode);
logger.info("Tcn passed by client is :" + tcn);
xmlAnnotation.setTcn(tcn); //explicitly setting TCN
Document xmlAnnotationDoc = xmlAnnotation.getDocument();
xmlAnnotationDoc.setUpdatedBy(updatedBy);
xmlAnnotationDoc.setUpdatedDate(new Date());
xmlAnnotationDoc.setCoCd(companyCode);

docDao.update(xmlAnnotationDoc);
xmlAnnotationDao.update(xmlAnnotation);
xmlAnnotationDao.flushHibernateSession();********************************************************

Here is mapping for the EstimateXmlAnnotation VO:

<hibernate-mapping schema="CLM" package="com.mitchell.services.technical.partialloss.estimate.bo">
<class
name="EstimateXmlAnnotation"
table="CLM_EST_XML_ANNOTATION"
>
<id
name="id"
type="java.lang.Long"
column="ANNOTATION_ID"
>
<generator class="sequence">
<param name="sequence">CLM_EST_XML_ANNOTATION_SEQ</param>
</generator>
</id>

<version name="tcn" column="TCN" type="java.lang.Long" unsaved-value="null"/>

<property
name="coCd"
column="CO_CD"
type="string"
not-null="true"
length="10"
/>
----so on and so forth..
******************************************************
This is the hibernate log I see (if this helps)

******************
17:12:13,603 DEBUG BasicEntityPersister:2595 - com.mitchell.services.technical.partialloss.estimate.bo.EstimateXmlAnnotation.tcn is dirty
17:12:13,603 DEBUG BasicEntityPersister:2595 - com.mitchell.services.technical.partialloss.estimate.bo.EstimateXmlAnnotation.updatedDate is dirty
17:12:13,603 DEBUG DefaultFlushEntityEventListener:121 - Updating entity: [com.mitchell.services.technical.partialloss.estimate.bo.EstimateXmlAnnotation#2034]
17:12:13,603 DEBUG Versioning:26 - Incrementing: 15 to 16
*****************************************

I really appriciate your help.
Thanks,
Manoj


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.