IBM Support

PI66770: JPA RETURNS INCORRECT RESULTS WHEN USING A NATIVE QUERY AND @SQLRESULTSETMAPPING

Fixes are available

9.0.0.2: WebSphere Application Server traditional V9.0 Fix Pack 2
8.5.5.11: WebSphere Application Server V8.5.5 Fix Pack 11
16.0.0.4: WebSphere Application Server Liberty 16.0.0.4
9.0.0.3: WebSphere Application Server traditional V9.0 Fix Pack 3
9.0.0.4: WebSphere Application Server traditional V9.0 Fix Pack 4
8.5.5.12: WebSphere Application Server V8.5.5 Fix Pack 12
9.0.0.5: WebSphere Application Server traditional V9.0 Fix Pack 5
9.0.0.6: WebSphere Application Server traditional V9.0 Fix Pack 6
8.5.5.13: WebSphere Application Server V8.5.5 Fix Pack 13
9.0.0.7: WebSphere Application Server traditional V9.0 Fix Pack 7
17.0.0.1: WebSphere Application Server Liberty 17.0.0.1
17.0.0.2: WebSphere Application Server Liberty 17.0.0.2
17.0.0.3: WebSphere Application Server Liberty 17.0.0.3
17.0.0.4: WebSphere Application Server Liberty 17.0.0.4
18.0.0.1: WebSphere Application Server Liberty 18.0.0.1
18.0.0.2: WebSphere Application Server Liberty 18.0.0.2
9.0.0.8: WebSphere Application Server traditional V9.0 Fix Pack 8
8.5.5.14: WebSphere Application Server V8.5.5 Fix Pack 14
9.0.0.9: WebSphere Application Server traditional V9.0 Fix Pack 9
18.0.0.3: WebSphere Application Server Liberty 18.0.0.3
9.0.0.10: WebSphere Application Server traditional V9.0 Fix Pack 10
18.0.0.4: WebSphere Application Server Liberty 18.0.0.4
19.0.0.1: WebSphere Application Server Liberty 19.0.0.1
8.5.5.15: WebSphere Application Server V8.5.5 Fix Pack 15
19.0.0.2: WebSphere Application Server Liberty 19.0.0.2
19.0.0.3: WebSphere Application Server Liberty 19.0.0.3
9.0.0.11: WebSphere Application Server traditional V9.0 Fix Pack 11
19.0.0.4: WebSphere Application Server Liberty 19.0.0.4
19.0.0.5: WebSphere Application Server Liberty 19.0.0.5
9.0.5.0: WebSphere Application Server traditional Version 9.0.5 Refresh Pack
19.0.0.6: WebSphere Application Server Liberty 19.0.0.6
19.0.0.7: WebSphere Application Server Liberty 19.0.0.7
19.0.0.8: WebSphere Application Server Liberty 19.0.0.8
9.0.5.1: WebSphere Application Server traditional Version 9.0.5 Fix Pack 1
19.0.0.9: WebSphere Application Server Liberty 19.0.0.9
19.0.0.10: WebSphere Application Server Liberty 19.0.0.10
19.0.0.11: WebSphere Application Server Liberty 19.0.0.11
9.0.5.2: WebSphere Application Server traditional Version 9.0.5 Fix Pack 2
19.0.0.12: WebSphere Application Server Liberty 19.0.0.12
20.0.0.1: WebSphere Application Server Liberty 20.0.0.1
20.0.0.2: WebSphere Application Server Liberty 20.0.0.2
8.5.5.17: WebSphere Application Server V8.5.5 Fix Pack 17
9.0.5.3: WebSphere Application Server traditional Version 9.0.5 Fix Pack 3
20.0.0.3: WebSphere Application Server Liberty 20.0.0.3
20.0.0.4: WebSphere Application Server Liberty 20.0.0.4
20.0.0.5: WebSphere Application Server Liberty 20.0.0.5
20.0.0.6: WebSphere Application Server Liberty 20.0.0.6
9.0.5.4: WebSphere Application Server traditional Version 9.0.5 Fix Pack 4
20.0.0.7: WebSphere Application Server Liberty 20.0.0.7
20.0.0.8: WebSphere Application Server Liberty 20.0.0.8
9.0.5.5: WebSphere Application Server traditional Version 9.0.5 Fix Pack 5
20.0.0.9: WebSphere Application Server Liberty 20.0.0.9
20.0.0.10: WebSphere Application Server Liberty 20.0.0.10
20.0.0.11: WebSphere Application Server Liberty 20.0.0.11
20.0.0.12: WebSphere Application Server Liberty 20.0.0.12
9.0.5.6: WebSphere Application Server traditional Version 9.0.5 Fix Pack 6

Subscribe

You can track all active APARs for this component.

 

APAR status

  • Closed as program error.

Error description

  • JPA returns incorrect results on BPM 8.5 when using a native
    query and @SqlResultSetMapping. Results were correct on BPM 7.5
    

Local fix

Problem summary

  • ****************************************************************
    * USERS AFFECTED:  All users of IBM WebSphere Application      *
    *                  Server V8.5.0, V8.5.5, and V9.0.0 who make  *
    *                  use of the JPA @SqlResultSetMapping         *
    *                  annotation and native queries.              *
    ****************************************************************
    * PROBLEM DESCRIPTION: IDs of entities are incorrectly         *
    *                      assigned when @SqlResultSetMapping is   *
    *                      used with inheritance and a ManyToOne   *
    *                      relationship.                           *
    ****************************************************************
    * RECOMMENDATION:                                              *
    ****************************************************************
    Incorrect JPA ID's are assigned when using
    @SqlResultSetMapping, combined with JPA inheritance and
    ManyToOne relationships. To explain the issue, take this
    entity and @SqlResultSetMapping:
    @Entity
    @SqlResultSetMapping(name = "MyResMap", entities = {
    @EntityResult(entityClass = ChequeEntity.class, fields ={
    @FieldResult(name = "operation.id", column =
    "opRecepcaoServCentraisId"),
    @FieldResult(name = "operation.dataHora", column =
    "opRecepcaoServCentraisDataHora") })})
    public class ChequeEntity extends RequestEntity {
    .......
    @ManyToOne
    @javax.persistence.JoinColumn(name =
    "OPERACAO_RECEPCAO_SERV_CENT", referencedColumnName = "ID")
    private OperationEntity operation;
    As you can see, this entity extends 'RequestEntity' and
    has a ManyToOne relationship to 'OperationEntity', with name
    'operation'. Furthermore, the @FieldResult in the
    @SqlResultSetMapping references the fields in
    'OperationEntity'. These two entities are defined as
    follows:
    @Entity
    @Inheritance(strategy = InheritanceType.JOINED)
    public class RequestEntity {
    .....
    @Id
    private long id;
    .....
    @Entity
    public class OperationEntity implements Serializable {
    .....
    @Id
    private long id;
    @Basic
    private Timestamp dataHora;
    .....
    With these entities, take an SQL select which uses an AS (the
    entire SQL is to long to add here):
    String sql = "SELECT t0.ID" +
    .........
    ",t2.dataHora as opRecepcaoServCentraisDataHora" +
    ",t2.ID as opRecepcaoServCentraisId" +
    ....
    "FROM ChequeEntity t0"
    ....
    "INNER JOIN OperationEntity t2"
    ....
    With this SQL, the two IDs will be populated with the ID from
    ChequeEntity, rather than the ID corresponding to each entity.
    

Problem conclusion

  • With this fix, code has been added to OpenJPA to ensure that
    the proper ID's are used for entities when the results are
    mapped via an @SqlResultSetMapping.
    
    The fix for this APAR is currently targeted for inclusion in
    Service Levels (Fix Packs) 8.5.5.11 and 9.0.0.2 of WebSphere
    Application Server versions 8.5.5 and 9.0.0, and fix pack
    16.0.0.4 for WebSphere Application Server Liberty.
    
    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

    PI66770

  • Reported component name

    WEBS APP SERV N

  • Reported component ID

    5724H8800

  • Reported release

    850

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt / Xsystem

  • Submitted date

    2016-08-01

  • Closed date

    2016-08-25

  • Last modified date

    2016-08-25

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

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

Fix information

  • Fixed component name

    WEBS APP SERV N

  • Fixed component ID

    5724H8800

Applicable component levels

  • R850 PSY

       UP

  • R900 PSY

       UP

[{"Business Unit":{"code":"BU053","label":"Cloud \u0026 Data Platform"},"Product":{"code":"SSEQTP","label":"WebSphere Application Server"},"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"850","Line of Business":{"code":"LOB36","label":"IBM Automation"}}]

Document Information

Modified date:
16 October 2021