]
Scott Marlow commented on HHH-5032:
-----------------------------------
Gail, the current fix is fine to release. I'm fine with moving this jira to the next
3.5.x release or whatever you want to do with it.
Best, Scott
Setting LockModeType.OPTIMISTIC_FORCE_INCREMENT defaults to only
OPTIMISTIC
---------------------------------------------------------------------------
Key: HHH-5032
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-5032
Project: Hibernate Core
Issue Type: Bug
Affects Versions: 3.5.0-CR-2, 3.5.1
Environment: Hibernate Core 3.5.0-CR-2, Hibernate Validator 4.1 Snapshot, Spring
3.0.1, JPA2
Reporter: Carlos Vara
Assignee: Scott Marlow
Fix For: 3.5.2, 3.6
Attachments: hhh5032-2.patch, hhh5032.patch, optimisticlocking.tar.gz
Using EntityManager.lock(entity, LockModeType.OPTIMISTIC_FORCE_INCREMENT) doesn't
change lock type, and version doesn't get updated on transaction commit.
The following code:
System.out.println("PRE lock mode: " + this.entityManager.getLockMode(an));
this.entityManager.lock(an, LockModeType.OPTIMISTIC_FORCE_INCREMENT);
System.out.println("POST lock mode: " + this.entityManager.getLockMode(an));
Outputs:
PRE lock mode: OPTIMISTIC
POST lock mode: OPTIMISTIC
Debugging AbstractLockUpgradeEventListener.upgradeLock, the reason is it doesn't
upgrade it because previous lock mode is "READ" (whose level is 5), and
OPTIMISTIC_FORCE_INCREMENT has level 4, so it doesn't trigger the update.
I'm not sure about Hibernate's LockMode, but I think that
OPTIMISTIC_FORCE_INCREMENT is a bit more restrictive than just OPTIMISTIC, so the locking
type should be upgraded.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: