IBM Support

PI12737: OPENJPA RUNS SUPERFLUOUS SELECT STATEMENT WHEN CALLING ENTITYMANAGER.PERSIST(..)

Subscribe

You can track all active APARs for this component.

 

APAR status

  • Closed as program error.

Error description

  • When calling EntityManager.persist(..) OpenJPA runs SELECT
    statements which are unrelated to the object graph to be
    persisted. This problem affects the OpenJPA implementation from
    Feature Pack for OSGi Applications and Java Persistence API 2.0
    and the implementation from WebSphere Application Server
    V8.5.5.1. When the TestClient is run the resulting SELECT
    statement is always printed:
    
    SELECT t0.test FROM OPENJPAPERSIST_REF t0 WHERE t0.id = ?
    [params=(long) 0]
    
    This statement should be avoided.
    

Local fix

  • na
    

Problem summary

  • ****************************************************************
    * USERS AFFECTED:  All users of IBM WebSphere Application      *
    *                  Server V8.0.0, V8.5.0, and V8.5.5 who make  *
    *                  use of a Cascade Persist and notice an      *
    *                  extra SQL statement because of it.          *
    ****************************************************************
    * PROBLEM DESCRIPTION: Extra queries being generated when      *
    *                      cascading a persist.                    *
    ****************************************************************
    * RECOMMENDATION:                                              *
    ****************************************************************
    A scenario exists where extra queries were being generated
    while cascading a persist to a new Entity. See the following
    example:
    @Entity
    public class CascadePersistEntity implements Serializable {
     ‚   ‚   ‚   ‚  @Id
     ‚   ‚   ‚   ‚  long id;
     ‚   ‚   ‚   ‚  @OneToOne(cascade = CascadeType.ALL)
     ‚   ‚   ‚   ‚  CascadePersistEntity other;
    ...
    }
    and the following scenario:
    CascadePersistEntity cpe1 = new CascadePersistEntity(1);
    CascadePersistEntity cpe2 = new CascadePersistEntity(2);
    cpe1.setOther(cpe2);
    em.persist(cpe1);
    This results in two inserts and one select.  The select
    doesn't not cause a problem, however it is not needed since
    the scenario only creates two new Entities.
    

Problem conclusion

  • With this fix, code has been added to OpenJPA to remove the
    extra select statement when cascade persisting an Entity.  The
    code for this APAR is enabled by a system property. The system
    property can be added to a persistence.xml file as follows:
    
    <property name="openjpa.Compatibility"
    value="CheckDatabaseForCascadePersistToDetachedEntity=false"/>
    
    Or this property can be added as a JVM system property rather
    than adding it to a persistence.xml file.
    
    
    The fix for this APAR is currently targeted for
    inclusion in Service Levels (Fix Packs) 8.0.0.10 and
    8.5.5.3 of WebSphere Application Server versions
    8.0.0 and 8.5.5.
    
    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

    PI12737

  • Reported component name

    WEBS APP SERV N

  • Reported component ID

    5724H8800

  • Reported release

    850

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt

  • Submitted date

    2014-02-28

  • Closed date

    2014-06-20

  • Last modified date

    2014-06-20

  • 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

  • R800 PSY

       UP

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

Document Information

Modified date:
28 April 2022