OpenJPA
  1. OpenJPA
  2. OPENJPA-1142

OptimisticLockException thrown on Query.getResultList() when Pessimistic Lock is applied

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.0-M3
    • Fix Version/s: 2.0.0-beta
    • Component/s: kernel
    • Labels:
      None
    • Patch Info:
      Patch Available

      Description

      The following sample code snippet may yield a OptimisticLockException.

      Query tc_query = itemManager.createNamedQuery("TypeCategory.find_tc").setParameter("product_id", new Integer(product_id));
      tc_query.setLockMode(LockModeType.PESSIMISTIC_READ);
      Collection typeCat = tc_query.getResultList();

      This is a incorrect behavior per JPA 2.0 spec:

      public interface Query {
      /**

      • Execute a SELECT query and return the query results
      • as an untyped List.
      • @return a list of the results
      • @throws IllegalStateException if called for a Java Persistence query language UPDATE or DELETE statement
      • @throws QueryTimeoutException if the query execution exceeds the query timeout value set
      • @throws TransactionRequiredException if a lock mode has been set and there is no transaction
      • @throws PessimisticLockException if pessimistic locking fails and the transaction is rolled back
      • @throws LockTimeoutException if pessimistic locking fails and only the statement is rolled back
        */
        List getResultList();

        Activity

        Albert Lee created issue -
        Albert Lee made changes -
        Field Original Value New Value
        Attachment OPENJPA-1142.patch [ 12411483 ]
        Albert Lee made changes -
        Patch Info [Patch Available]
        Hide
        Donald Woods added a comment -

        Code was checked in for this JIRA, so can it be marked as resolved?

        Show
        Donald Woods added a comment - Code was checked in for this JIRA, so can it be marked as resolved?
        Albert Lee made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Fix Version/s 2.0.0-beta2 [ 12314802 ]
        Resolution Fixed [ 1 ]
        Albert Lee made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Donald Woods made changes -
        Fix Version/s 2.0.0-beta [ 12314149 ]
        Fix Version/s 2.0.0 [ 12314019 ]
        Fix Version/s 2.0.0-beta2 [ 12314802 ]
        Affects Version/s 2.0.0-M3 [ 12314148 ]
        Affects Version/s 2.0.0-M2 [ 12313483 ]
        Affects Version/s 2.0.0 [ 12314019 ]
        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open Resolved Resolved
        254d 4h 46m 1 Albert Lee 03/Mar/10 23:37
        Resolved Resolved Closed Closed
        7s 1 Albert Lee 03/Mar/10 23:37

          People

          • Assignee:
            Albert Lee
            Reporter:
            Albert Lee
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development