[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-5032?page=c...
]
Scott Marlow commented on HHH-5032:
-----------------------------------
Thanks for the test case, could you merge the test into file
./entitymanager/src/test/java/org/hibernate/ejb/test/lock/LockTest.java? If you could do
so and attach a patch (result of executing subversion diff in project root folder, as in
"svn diff > hhh5032.patch").
We can discuss further if your not configured to build/run the Hibernate unit tests. So
info is here
http://hibernate.org/sourcecode.html
I'll assign the jira back to you. You can assign back to me after the test case is
converted into a unit test.
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
Attachments: 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:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira