IBM Support

PM59109: WHEN A MERGE IS DONE ON A NEW OBJECT WITH AN ID THAT CONTAINS AN ENTITY, INVALIDSTATEEXCEPTION OCCURS

Subscribe

You can track all active APARs for this component.

 

APAR status

  • Closed as program error.

Error description

  • When a merge is done on a new object with an Id that contains an
    Entity, the following exception occurs:
    
    <openjpa-2.2.1-SNAPSHOT-r422266:1292578 nonfatal user error>
    org.apache.openjpa.persistence.InvalidStateException: Attempt to
    change a primary key field of an instance that already has a
    final object id. Only new, unflushed instances whose id you have
    not retrieved can have their primary keys changed.
    FailedObject: hat.entities.Child@38d138d1
    at
    org.apache.openjpa.kernel.StateManagerImpl.assertNoPrimaryKeyCha
    nge(StateManagerImpl.java:2108)
    at
    org.apache.openjpa.kernel.StateManagerImpl.settingObjectField(St
    ateManagerImpl.java:2043)
    at
    org.apache.openjpa.kernel.AttachStrategy.attachField(AttachStrat
    egy.java:236)
    at
    org.apache.openjpa.kernel.VersionAttachStrategy.attach(VersionAt
    tachStrategy.java:155)
    at
    org.apache.openjpa.kernel.AttachManager.attach(AttachManager.jav
    a:252)
    at
    org.apache.openjpa.kernel.AttachStrategy.attachCollection(Attach
    Strategy.java:370)
    at
    org.apache.openjpa.kernel.AttachStrategy.replaceList(AttachStrat
    egy.java:431)
    at
    org.apache.openjpa.kernel.AttachStrategy.attachField(AttachStrat
    egy.java:255)
    at
    org.apache.openjpa.kernel.AttachManager.handleCascade(AttachMana
    ger.java:267)
    at
    org.apache.openjpa.kernel.AttachManager.attach(AttachManager.jav
    a:241)
    at
    org.apache.openjpa.kernel.AttachManager.attach(AttachManager.jav
    a:105)
    at
    org.apache.openjpa.kernel.BrokerImpl.attach(BrokerImpl.java:3474
    )
    at
    org.apache.openjpa.kernel.DelegatingBroker.attach(DelegatingBrok
    er.java:1214)
    at
    org.apache.openjpa.persistence.EntityManagerImpl.merge(EntityMan
    agerImpl.java:878)
    ...
    
    During the merge, a copy is made of the original object, with a
    copy of the key fields. But, if a key field is an Entity, it is
    not copied, causing this exception in later processing. The fix
    is to attach this field immediately after the original object is
    copied.
    

Local fix

  • N/A
    

Problem summary

  • ****************************************************************
    * USERS AFFECTED:  All users of IBM WebSphere Application      *
    *                  Server V8                                   *
    ****************************************************************
    * PROBLEM DESCRIPTION: An InvalidStateException is thrown when *
    *                      attempting to perform a merge operation *
    *                      on an entity that uses an entity for    *
    *                      its                                     *
    *                      id.                                     *
    ****************************************************************
    * RECOMMENDATION:                                              *
    ****************************************************************
    When a merge is done on a new object with an Id that contains
    an
    Entity, the following exception occurs:
    <openjpa-2.2.1-SNAPSHOT-r422266:1292578 nonfatal user error>
    org.apache.openjpa.persistence.InvalidStateException: Attempt
    to
    change a primary key field of an instance that already has a
    final object id. Only new, unflushed instances whose id you
    have
    not retrieved can have their primary keys changed.
    FailedObject: hat.entities.Child@38d138d1
    at
    org.apache.openjpa.kernel.StateManagerImpl.assertNoPrimaryKeyCha
    nge(StateManagerImpl.java:2108)
    at
    org.apache.openjpa.kernel.StateManagerImpl.settingObjectField(St
    ateManagerImpl.java:2043)
    at
    org.apache.openjpa.kernel.AttachStrategy.attachField(AttachStrat
    egy.java:236)
    at
    org.apache.openjpa.kernel.VersionAttachStrategy.attach(VersionAt
    tachStrategy.java:155)
    at
    org.apache.openjpa.kernel.AttachManager.attach(AttachManager.jav
    a:252)
    at
    org.apache.openjpa.kernel.AttachStrategy.attachCollection(Attach
    Strategy.java:370)
    at
    org.apache.openjpa.kernel.AttachStrategy.replaceList(AttachStrat
    egy.java:431)
    at
    org.apache.openjpa.kernel.AttachStrategy.attachField(AttachStrat
    egy.java:255)
    at
    org.apache.openjpa.kernel.AttachManager.handleCascade(AttachMana
    ger.java:267)
    at
    org.apache.openjpa.kernel.AttachManager.attach(AttachManager.jav
    a:241)
    at
    org.apache.openjpa.kernel.AttachManager.attach(AttachManager.jav
    a:105)
    at
    org.apache.openjpa.kernel.BrokerImpl.attach(BrokerImpl.java:3474
    )
    at
    org.apache.openjpa.kernel.DelegatingBroker.attach(DelegatingBrok
    er.java:1214)
    at
    org.apache.openjpa.persistence.EntityManagerImpl.merge(EntityMan
    agerImpl.java:878)
    ...
    During the merge, a copy is made of the original object, with a
    copy of the key fields. But, if a key field is an Entity, it is
    not copied, causing this exception in later processing.
    

Problem conclusion

  • The algorithm for managing the merge operation has been fixed.
    The fix is to attach this field immediately after the original
    object is copied.
    
    The fix for this APAR is currently targeted for inclusion in
    fix pack 8.0.0.4 and 8.5.0.1.  Please refer to the Recommended
    Updates page for delivery information:
    http://www.ibm.com/support/docview.wss?rs=180&uid=swg27004980
    

Temporary fix

Comments

APAR Information

  • APAR number

    PM59109

  • Reported component name

    WEBS APP SERV N

  • Reported component ID

    5724H8800

  • Reported release

    800

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt

  • Submitted date

    2012-02-27

  • Closed date

    2012-05-15

  • Last modified date

    2012-05-15

  • APAR is sysrouted FROM one or more of the following:

  • APAR is sysrouted TO one or more of the following:

    PM59383

Fix information

  • Fixed component name

    WEBSPHERE APP S

  • Fixed component ID

    5724J0800

Applicable component levels

  • R800 PSY

       UP

[{"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Product":{"code":"SSEQTP","label":"WebSphere Application Server"},"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"8.0","Line of Business":{"code":"LOB45","label":"Automation"}}]

Document Information

Modified date:
28 October 2021