[ 
https://issues.apache.org/jira/browse/OPENJPA-891?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12679991#action_12679991
 ] 

Albert Lee commented on OPENJPA-891:
------------------------------------

More testing reveals there exist 2 problems in the current implementations:

1) e.lock() does not honor the following contract

* @throws IllegalArgumentException if the instance is not an entity or is a 
detached entity, E.g.

      e = em.lock(null,LockModeType.XXX);
      e = em.lock("xxxx",LockModeType.XXX);

2) e.refresh does not honor the WRITE lock contract.

3.4.3 Lock Modes
"If transaction T1 calls lock(entity, LockModeType.WRITE) on a versioned 
object, the entity manager must avoid the phenomena P1 and P2 (as with  
LockModeType.READ) and must also force an update (increment) to the entity's 
version column. A forced version update may be performed immediately, or may be 
deferred until a flush or commit." E.g.

     e = em.find(Entity.class, 1);
     em.refresh(e, LockModeType.WRITE)
     em.getTransaction.commit();

does not update the version field on commit. but the lock did force the version 
to be updated.
     e = em.find(Entity.class, 1);
     em.lock(e, LockModeType.WRITE)
     em.getTransaction.commit();

More corrective patch and test cases will be posted later.
Albert Lee.

> JPA2 LockTypeMode Support
> -------------------------
>
>                 Key: OPENJPA-891
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-891
>             Project: OpenJPA
>          Issue Type: Sub-task
>          Components: jpa
>    Affects Versions: 2.0.0
>            Reporter: Albert Lee
>            Assignee: Albert Lee
>             Fix For: 2.0.0
>
>


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to