[hibernate-issues] [Hibernate-JIRA] Closed: (HHH-5032) Setting LockModeType.OPTIMISTIC_FORCE_INCREMENT defaults to only OPTIMISTIC

Steve Ebersole (JIRA) noreply at atlassian.com
Fri Jul 16 15:28:14 EDT 2010


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

Steve Ebersole closed HHH-5032.
-------------------------------


> 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: 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