org.apache.openjpa.persistence.ArgumentException: Attempt to assign id "0" to new instance "my.package.A-0" failed; there is already an object in the L1 cache with this id. You must delete this object (in a previous transaction or the current one) before reusing its id. This error can also occur when a horizontally or vertically mapped classes uses auto-increment application identity and does not use a hierarchy of application identity classes. FailedObject: my.package.A-0

openjpa-users | padamstx | 2 years ago
tip
Click on the to mark the solution that helps you, Samebug will learn from it.
As a community member, you’ll be rewarded for you help.
  1. 0

    Problem when using @Generated with non-primary key column

    openjpa-users | 2 years ago | padamstx
    org.apache.openjpa.persistence.ArgumentException: Attempt to assign id "0" to new instance "my.package.A-0" failed; there is already an object in the L1 cache with this id. You must delete this object (in a previous transaction or the current one) before reusing its id. This error can also occur when a horizontally or vertically mapped classes uses auto-increment application identity and does not use a hierarchy of application identity classes. FailedObject: my.package.A-0

    Root Cause Analysis

    1. org.apache.openjpa.persistence.ArgumentException

      Attempt to assign id "0" to new instance "my.package.A-0" failed; there is already an object in the L1 cache with this id. You must delete this object (in a previous transaction or the current one) before reusing its id. This error can also occur when a horizontally or vertically mapped classes uses auto-increment application identity and does not use a hierarchy of application identity classes. FailedObject: my.package.A-0

      at org.apache.openjpa.kernel.ManagedCache.commitNew()
    2. OpenJPA Aggregate Jar
      BrokerImpl.endTransaction
      1. org.apache.openjpa.kernel.ManagedCache.commitNew(ManagedCache.java:236)
      2. org.apache.openjpa.kernel.BrokerImpl.setStateManager(BrokerImpl.java:4145)
      3. org.apache.openjpa.kernel.StateManagerImpl.commit(StateManagerImpl.java:1164)
      4. org.apache.openjpa.kernel.BrokerImpl.endTransaction(BrokerImpl.java:2433)
      4 frames