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

Pinaki Poddar commented on OPENJPA-1604:
----------------------------------------

The setting of lock modes based on current lock manager seems to be ambiguous 
at few places both in usage and in design/code.

>From a usage point of view, 
  a) setting a specific lock manager be it pessimistic or optimistic should 
impose a specific default read and write lock level for all queries. 
  b) that default level can be overwritten by 
       i) setting query.setLockMode()
      ii) setting lockMode attribute of @NamedQuery
     iii) setting query hints
      iv) passing lock properties in find() etc.

  c) the semantics of a joint specification such as 
        <property name="openjpa.LockManager" value="pessimistic"/>
        <property name="openjpa.Optimistc" value="true"/>
      also appears confusing/contradictory. We should either detect 
specification that are contradictory or clarify what such apparently 
contradictory specifications imply.

>From a design/code point of view,
   a) setting a FetchPlan.Lock hint during annotation parsing does not look 
good to me. We have reasonable data structures to capture meta information on a 
query and that seems to be the right place for lock information rather than a 
fetch plan hint.
   b) the default read/write lock levels should be dictated by the currently 
active lock manager. LockManager.beginTransaction() seems to be one correct 
place to populate the fetch configuration with these levels. Outside 
transaction, fetch plan initialization should take current Lock Manager into 
consideration to set its read/write lock levels.
   c) OpenJPAConfiguration should impose consistency between LockManager and 
setOptimistic() 
  


> Setting PessimisticLockManager fails to append "for update clause" to the 
> select statement
> ------------------------------------------------------------------------------------------
>
>                 Key: OPENJPA-1604
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-1604
>             Project: OpenJPA
>          Issue Type: Bug
>    Affects Versions: 2.1.0
>            Reporter: Fay Wang
>
>  I ran a testcase against openjpa 1.2, and found that the "for update" clause 
> is appended to the SQL when
>               <property name="openjpa.LockManager" value="pessimistic"/>
>       is added to the persistence.xml without calling: 
>                q.setLockMode(LockModeType.PESSIMISTIC_WRITE);
> However, this behavior changes when running against trunk level code

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