[hibernate-issues] [Hibernate-JIRA] Closed: (HHH-1112) StaleObjectStateException not being thrown when expected

Steve Ebersole (JIRA) noreply at atlassian.com
Mon Mar 21 13:00:55 EDT 2011


     [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1112?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Steve Ebersole closed HHH-1112.
-------------------------------


Closing stale resolved issues

> StaleObjectStateException not being thrown when expected
> --------------------------------------------------------
>
>                 Key: HHH-1112
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1112
>             Project: Hibernate Core
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 3.0.5
>         Environment: Windows XP with JDK 1.4.2
> Hibernate 3.0.5
> Oracle database 9i
>            Reporter: Virinder Singh
>
> Hi,
> We use modify_timestamp as our managed versioning.
> We have a scenario in a web application where we do the following steps:
> (1) Retrieve event with id="1234". (called eventDTO1 which reads its values from event POJO) (modify timestamp say 1 pm)
> (2) Retrieve another event with same id="1234" (called eventDTO2 which reads its values from event POJO) (modify timestamp say 1:10 pm)
> (3) Make some updates in presentation layer to some attributes of eventDTO2 and send it to persistence layer for update. Persistence layer retrieved event POJO and updated its attributes from eventDTO2. Everything is updated succesfully and modify timestamp is updated to current time (say 1:20 pm)
> (4) Now make some updates to eventDTO1 and send it to persistence layer, persistence layer retrieved event POJO and updated its attributes from eventDTO1. we expected to see StateObjectStateException but everything gets updated successfully and modify_timestamp is updated to say 1:30 pm (which was when we did update for event)
> When I look at the reason why the update went through succesfully, I found that the following query was used:
> 2005-10-28 13:55:15,969 [main] DEBUG org.hibernate.SQL - update SUBMISSIONS set MODIFY_TIMESTAMP=?, MODIFY_ID=? where ID=? and MODIFY_TIMESTAMP=?
> The actual query with values (in pseudo-code) looks like this:
> update SUBMISSIONS set MODIFY_TIMESTAMP="1:30 pm", modify_id='ABCD' where is='1234' and MODIFY_TIMESTAMP="1:20 pm";
> (this query will always succeed since the value of MODIFY_TIMESTAMP used in where clause is value stored in database (previousState) and not currentState which will be set from presentation layer)
> The MODIFY_TIMESTAMP that we should expect to be used in the where clause is the one held in eventDTO1 (which was 1:10 pm)
> But the value that was used in MODIFY_TIMESTAMP in where clause was 1:20 pm and not 1:10 pm which would have triggered StaleObjectStateException. 1:20 pm was time when eventDTO2 in step 3 was successfully updated. I found these values reliably by using p6spy.
> Hibernate should be using the modify_timestamp value that is coming from presentation layer and not the current modify_timestamp value stored in database.
> I am using following attributes in all in hbm xml files:
> <class 
>     name="gov.ca.doj.sins.riss.model.Submission" 
>     table="SUBMISSIONS" select-before-update="true" dynamic-update="true" optimistic-lock="version"
> >
> ...
> ...
> <timestamp name="modifyTimestamp" column="MODIFY_TIMESTAMP" />
> Thanks in advance,
> -Virinder.
>  

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list