IBM Support

PM62988: UPDATING A JPA ENTITY CONTAINING A ELEMENTCOLLECTION FAILS

Subscribe

You can track all active APARs for this component.

 

APAR status

  • Closed as program error.

Error description

  • While updating a JPA entity containing an elementCollection,
    which in turn references two foreign keys of the same type, the
    wrong query is generated, inserting the same values for the
    foreign keys.
    

Local fix

  • N/A
    

Problem summary

  • ****************************************************************
    * USERS AFFECTED:  All users of the Java Persistence API       *
    *                  (JPA) 2.0 feature of the IBM WebSphere      *
    *                  Application Server V7 Feature Pack for      *
    *                  OSGi Applications and Java Persistence API  *
    *                  2.0  who make use of @ElementCollection     *
    *                  with multiple relationships.                *
    ****************************************************************
    * PROBLEM DESCRIPTION: An incorrect value is persisted with    *
    *                      multiple foreign keys of the same       *
    *                      type.                                   *
    ****************************************************************
    * RECOMMENDATION:                                              *
    ****************************************************************
    When an entity contains 2 or more relationships (for example,
    @ManyToOne), each with a type of the same entity, and a
    foreign key table is generated with each of them as an id, 1
    or more of the id values are wrong.  The following is an
    example of the entities involved which cause the issue:
    @Entity
    public class TopLevel implements Serializable {
    .......
    @Id
    private long id;
    @ElementCollection
    private Collection<ContainsMultSimpleEntity> contMultSEColl;
    .......
    Where ContainsMultSimpleEntity is deinfed as follows:
    @Embeddable
    public class ContainsMultSimpleEntity implements
    Serializable {
    .......
    @ManyToOne(cascade=CascadeType.ALL)
    @JoinColumn(nullable=false)
    private SimpleEntity simpleEntity1;
    @ManyToOne(cascade=CascadeType.ALL)
    @JoinColumn(nullable=false)
    private SimpleEntity simpleEntity2;
    @ManyToOne(cascade=CascadeType.ALL)
    @JoinColumn(nullable=false)
    private SimpleEntity simpleEntity3;
    .......
    And SimpleEntity is, as its name suggests, a simple entity
    definition as follows:
    @Entity
    public class SimpleEntity implements Serializable {
    @Id
    private long id;
    With the above entities (note the use of @ElementCollection
    and the definition of many @ManyToOne fields), there exists the
    potential for multiple SimpleEntity instances to be inserted
    with the same id.
    

Problem conclusion

  • With this fix code has been added to OpenJPA to ensure the
    correct foreign key is used when working with entities of the
    same type in an @ElementCollection.
    
    The fix for this APAR is currently targeted for inclusion
    in Fix Pack 1.0.0.9 for the Feature Pack for OSGi Applications
    and Java Persistence API 2.0.
    
    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

    PM62988

  • Reported component name

    JPA OSGI FEATUR

  • Reported component ID

    5724J0857

  • Reported release

    700

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt

  • Submitted date

    2012-04-21

  • Closed date

    2012-06-25

  • Last modified date

    2012-06-25

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

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

    PM64810

Fix information

  • Fixed component name

    JPA OSGI FEATUR

  • Fixed component ID

    5724J0857

Applicable component levels

  • R700 PSY

       UP

[{"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Product":{"code":"SSEQTP","label":"WebSphere Application Server"},"Component":"","ARM Category":[],"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"1.0","Edition":"","Line of Business":{"code":"LOB45","label":"Automation"}}]

Document Information

Modified date:
29 September 2020