OpenJPA
  1. OpenJPA
  2. OPENJPA-2107

ManagedCache conflict due adding an entity 2 times in the same query.

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.1, 2.1.0, 2.2.0
    • Fix Version/s: 1.2.3, 2.0.2, 2.1.2, 2.2.0
    • Component/s: kernel
    • Labels:
      None

      Description

      I have a complex query which creates the following error:

      <openjpa-2.2.0-tiss-2-rexported nonfatal user error> org.apache.openjpa.persistence.ArgumentException: Cannot load object with id "26301". Instance "at.ac.tuwien.tiss.curriculum.be.entities.DefaultCourse@6e267b76" with the same id already exists in the L1 cache. This can occur when you assign an existing id to a new instance, and before flushing attempt to load the existing instance for that id.
      FailedObject: at.ac.tuwien.tiss.curriculum.be.entities.DefaultCourse-26301
      at org.apache.openjpa.kernel.ManagedCache.add(ManagedCache.java:126)
      at org.apache.openjpa.kernel.BrokerImpl.setStateManager(BrokerImpl.java:4117)
      at org.apache.openjpa.kernel.StateManagerImpl.initialize(StateManagerImpl.java:391)
      at org.apache.openjpa.kernel.StateManagerImpl.initialize(StateManagerImpl.java:340)
      at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.initializeState(JDBCStoreManager.java:378)

      It seems that this entity gets loaded from the db twice in the same query.

      While hitting the problem, the StateManagers have the following _flags:

      orig _flags= 602 = 0010 0101 1010 SAVE LOADED READ_LOCKED OID_ASSIGNED FLUSHED
      sm _flags= 16 = 0000 0001 0000 READ_LOCKED

      And it is really only 1 instance which makes this problem. If I set the 'orig' variable to null in the debugger, the test runs fine.

        Issue Links

          Activity

          Mark Struberg created issue -
          Rick Curtis made changes -
          Field Original Value New Value
          Attachment OPENJPA-2107.patch [ 12510384 ]
          Rick Curtis made changes -
          Assignee Mark Struberg [ struberg ] Rick Curtis [ curtisr7 ]
          Rick Curtis made changes -
          Link This issue relates to OPENJPA-2051 [ OPENJPA-2051 ]
          Rick Curtis made changes -
          Assignee Rick Curtis [ curtisr7 ] Heath Thomann [ jpaheath ]
          Affects Version/s 2.1.0 [ 12314542 ]
          Affects Version/s 2.0.1 [ 12314532 ]
          Albert Lee made changes -
          Status Open [ 1 ] Resolved [ 5 ]
          Resolution Fixed [ 1 ]
          Albert Lee made changes -
          Status Resolved [ 5 ] Closed [ 6 ]
          Heath Thomann made changes -
          Resolution Fixed [ 1 ]
          Status Closed [ 6 ] Reopened [ 4 ]
          Heath Thomann made changes -
          Status Reopened [ 4 ] Resolved [ 5 ]
          Fix Version/s 1.2.3 [ 12314517 ]
          Fix Version/s 2.0.2 [ 12315257 ]
          Fix Version/s 2.1.2 [ 12317142 ]
          Resolution Fixed [ 1 ]
          Heath Thomann made changes -
          Status Resolved [ 5 ] Closed [ 6 ]

            People

            • Assignee:
              Heath Thomann
              Reporter:
              Mark Struberg
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development