IBM Support

PI44859: ERROR WHEN TRYING TO FORCE AN EAGER FETCH ON A QUERY

Subscribe

You can track all active APARs for this component.

 

APAR status

  • Closed as program error.

Error description

  • Client is  trying to force an eager fetch on a query. They  are
    using OpenJPAs FetchPlan to do so. Here s how they are doing
    it: (as per documentation
    
    FetchPlan fetchPlan =
    query.unwrap(OpenJPAQuery.class).getFetchPlan();
    fetchPlan.addField(Compra.class, "apostador");
    
    On the first time the query is executed, it works as expected.
    However,  on the second time the same query is executed, and
    the result comes  from OpenJPA s cache, it doesn t work. The
    relationship attribute comes as null.
    
    not the Query s FetchPlan), it works as expected: it is always
    eagerly
    fetched. See the example below:
    
    FetchPlan fetchPlan =
    getEntityManager().unwrap(OpenJPAEntityManager.
    class).getFetchPlan();
    fetchPlan.addField(Compra.class, "apostador");
    

Local fix

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 OpenJPA QueryCache and FetchPlans.   *
    ****************************************************************
    * PROBLEM DESCRIPTION: Incorrect JPA relationship data         *
    *                      returned when QueryCache and            *
    *                      FetchPlans are used.                    *
    ****************************************************************
    * RECOMMENDATION:                                              *
    ****************************************************************
    A scenario exist where incorrect data is returned
    when the DataCache, QueryCache, and FetchPlans are used.  To
    explain, take these very simple entities and relationship:
    @Entity
    public class Entity1 {
    @Id
    private int id;
    @OneToOne(fetch = FetchType.LAZY)
    private Entity2 ent2;
    ........
    @Entity
    public class Entity2 {
    @Id
    private Long id;
    ......
    Given these two entities, take this scenario:
    Query q = em.createQuery("Select e1 from Entity1 e1");
    FetchPlan fetchPlan =
    q.unwrap(OpenJPAQuery.class).getFetchPlan();
    fetchPlan.addField(Entity1.class, "ent2");
    List<Entity1> results = (List<Entity1>) q.getResultList();
    em.clear();
    assertNotNull("No results returned!", results);
    for (Entity1 e1 : results)
    { assertNotNull("An 'Entity2' should have been returned!",
    e1.getEnt2()); }
    With this code, assume the DataCache and QueryCache are both
    enabled, and assume there is an Entity1 with an Entity2 in the
    database.  When we run this code all works fine.  However,
    if we run the code back to back using the same
    EntityManagerFactory, an Entity1 will be returned but its
    Entity2 will be null!  If on the other hand, we run the
    code 3 times in a row, where there is a time lag between the
    2nd and 3rd execution greater than the DataCache timeout, the
    correct data will be returned during the 3rd run.
    

Problem conclusion

  • With this fix, code has been added to OpenJPA to ensure that
    the proper relationship data is returned when QueryCache and
    FetchPlans are used.
    
    The fix for this APAR is currently targeted for
    inclusion in Service Levels (Fix Packs) 8.0.0.12 and 8.5.5.8
    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

    PI44859

  • Reported component name

    WEBSPHERE APP S

  • Reported component ID

    5724J0800

  • Reported release

    800

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt / Xsystem

  • Submitted date

    2015-07-13

  • Closed date

    2015-10-16

  • Last modified date

    2015-10-16

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

    PI41046

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

Fix information

  • Fixed component name

    WEBSPHERE APP S

  • Fixed component ID

    5724J0800

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

Document Information

Modified date:
27 April 2022