IBM Support

PM70209: 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, a
    wrong query is generated, inserting the same values for the
    foreign keys.
    

Local fix

  • N/A
    

Problem summary

  • ****************************************************************
    * USERS AFFECTED:  All users of IBM WebSphere Application      *
    *                  Server V8.0.0 and V8.5.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 (e.g.
    @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 causes 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 Service Levels (Fix Packs) 8.0.0.5 and 8.5.0.1 of
    WebSphere Application Server version 8.0.0 and 8.5.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

    PM70209

  • Reported component name

    LIBERTY PROFILE

  • Reported component ID

    5724J0814

  • Reported release

    850

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt

  • Submitted date

    2012-08-03

  • Closed date

    2012-08-03

  • Last modified date

    2012-08-03

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

    PM64810

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

Fix information

  • Fixed component name

    LIBERTY PROFILE

  • Fixed component ID

    5724J0814

Applicable component levels

  • R850 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":"850","Line of Business":{"code":"LOB45","label":"Automation"}}]

Document Information

Modified date:
29 October 2021