updated object version property only updates after transaction commit
---------------------------------------------------------------------
Key: HHH-6135
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-6135
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.5.6
Environment: 3.5.6-Final, Oracle 10/11G
linux and windows sun java 6 1.6.0_24
Reporter: Dave Birch
I'm noticing that updates are not incrementing versions on the objects being updated
until after transaction completion - so logic during the transaction after the .update()
call don't get the to-be version count.
In our case we have some integrated workflow, and we're creating changelog digests
with reference to the previous entity, and as the version counters don't increment
until the final tx completes (we use spring @Transactional) the compares contain the same
version number as previous.
{code}
@Transactional
submitUpdate(entity) {
int initialV = entity.getVersion();
hibernate.update(entity, null); //note this is actually performed by a spring hibernate
template - method body below (it essentially just calls session.update()
//at this point x.getVersion() will still be same as initialV
createWorkflow(x); //create workflow & submit within same TX (note - this does not
save the entity again - just some totally separate other objects & jms etc)
}
//from spring hibernate template (v3.0.3-RELEASE)
public void update(final Object entity, final LockMode lockMode) throws
DataAccessException {
executeWithNativeSession(new HibernateCallback<Object>() {
public Object doInHibernate(Session session) throws HibernateException {
checkWriteOperationAllowed(session);
session.update(entity);
if (lockMode != null) {
session.lock(entity, lockMode);
}
return null;
}
});
}
{code}
The update works perfectly if i take away the @Transactional & do each in new
transactions, but i think this is highlighting a change that the object (and child objects
participating in the tx too) are not consistent thoughout the tx.
I can't update to 3.6 or 4 to check this yet, but prev to 3.5.6 we were able to
manually adjust the value prior to submit to the createWorkflow() and then set it back
after - in 3.5.6 this causes the version counter to increment by 2 after tx completion.
--
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....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira