Uploaded image for project: 'OpenJPA'
  1. OpenJPA
  2. OPENJPA-494

Single Table Inheritance Strategy causes errors when reading entities from the database (discriminator problem)

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.0.0, 1.0.1, 1.1.0
    • 1.2.0
    • None
    • None
    • Windows XP, Java 5.0 IBM

    Description

      It appears that versions from 1.0 don't handle correctly discriminating objects received from the datastore when the inheritance strategy is set to SINGLE_TABLE.

      Error I receive from test cases (attached):

      <openjpa-1.0.1-r420667:592145 nonfatal user error> org.apache.openjpa.persistence.ArgumentException: Cannot load object with id "2". Instance "jpa.Admin-2" 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: jpa.Admin-2

      This problem doesn't occur in OpenJPA version 0.9.7.

      Trace:
      <openjpa-1.0.1-r420667:592145 nonfatal user error> org.apache.openjpa.persistence.ArgumentException: Cannot load object with id "2". Instance "jpa.Admin-2" 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: jpa.Admin-2
      at org.apache.openjpa.kernel.BrokerImpl$ManagedCache.add(BrokerImpl.java:4444)
      at org.apache.openjpa.kernel.BrokerImpl.setStateManager(BrokerImpl.java:3779)
      at org.apache.openjpa.kernel.StateManagerImpl.initialize(StateManagerImpl.java:303)
      at org.apache.openjpa.kernel.StateManagerImpl.initialize(StateManagerImpl.java:264)
      at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.initializeState(JDBCStoreManager.java:330)
      at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.initialize(JDBCStoreManager.java:255)
      at org.apache.openjpa.kernel.DelegatingStoreManager.initialize(DelegatingStoreManager.java:111)
      at org.apache.openjpa.kernel.ROPStoreManager.initialize(ROPStoreManager.java:57)
      at org.apache.openjpa.kernel.BrokerImpl.initialize(BrokerImpl.java:843)
      at org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:801)
      at org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:723)
      at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.find(JDBCStoreManager.java:748)
      at org.apache.openjpa.jdbc.meta.strats.RelationFieldStrategy.load(RelationFieldStrategy.java:570)
      at org.apache.openjpa.jdbc.meta.FieldMapping.load(FieldMapping.java:802)
      at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.load(JDBCStoreManager.java:485)
      at org.apache.openjpa.kernel.DelegatingStoreManager.load(DelegatingStoreManager.java:116)
      at org.apache.openjpa.kernel.ROPStoreManager.load(ROPStoreManager.java:78)
      at org.apache.openjpa.kernel.StateManagerImpl.loadFields(StateManagerImpl.java:2867)
      at org.apache.openjpa.kernel.StateManagerImpl.loadField(StateManagerImpl.java:2945)
      at org.apache.openjpa.kernel.StateManagerImpl.beforeAccessField(StateManagerImpl.java:1449)
      at org.apache.openjpa.kernel.StateManagerImpl.accessingField(StateManagerImpl.java:1434)
      at jpa.RegularUser.pcGetadmin(RegularUser.java)
      at jpa.RegularUser.getAdmin(RegularUser.java:16)
      at TestCase.testL1ProductEasier(TestCase.java:38)

      Attachments

        1. SingleTableDiscriminatorProblem.zip
          15 kB
          Przemek Koprowski

        Activity

          People

            ppoddar@apache.org Pinaki Poddar
            corp Przemek Koprowski
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: