IBM Support

PI26049: OpenJPA PersistenceException: LongId cannot be cast to <class name>

Subscribe

You can track all active APARs for this component.

 

APAR status

  • Closed as program error.

Error description

  • Try to get an object from my database via entity manager that
    includes a further object that is annotated with @OneToMany and
    the parameter "fetch = FetchType.EAGER", I got the following:
    
    [ERROR 15:50:40] projectNameRestController.catchEmAll(75) |
    general error occurred
    <openjpa-2.2.2-r422266:1468616 nonfatal general error>
    org.apache.openjpa.persistence.PersistenceException:
    org.apache.openjpa.util.LongId cannot be cast to
    de.projectName.domain.test.Parent
    FailedObject: select p from Parent p [java.lang.String]
    at
    org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:1027)
    at
    org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:926)
    at
    org.apache.openjpa.jdbc.kernel.JDBCStoreManager.load(JDBCStoreMa
    nager.java:1033)
    at
    org.apache.openjpa.jdbc.sql.AbstractResult.load(AbstractResult.j
    ava:280)
    at
    org.apache.openjpa.jdbc.sql.SelectImpl$SelectResult.load(SelectI
    mpl.java:2381)
    
    This was also reported in the open JPA JIRA OPENJPA-2505
    https://issues.apache.org/jira/browse/OPENJPA-2505
    

Local fix

  • n/a
    

Problem summary

  • ****************************************************************
    * USERS AFFECTED:  All users of IBM WebSphere Application      *
    *                  Server V8.5.5 who make use of the JPA       *
    *                  CriteriaBuilder.                            *
    ****************************************************************
    * PROBLEM DESCRIPTION: OpenJPA PersistenceException: LongId    *
    *                      cannot be cast to <class name>          *
    ****************************************************************
    * RECOMMENDATION:                                              *
    ****************************************************************
    The following exception can occur when getting the Criteria
    Builder from JPA (EntityManagerFactory.getCriteriaBuilder()):
    org.apache.openjpa.persistence.PersistenceException:
    org.apache.openjpa.util.LongId cannot be cast to
    org.apache.openjpa.MyEntity
    It is difficult to cause this exception and the scenario is
    very narrow.  This exception occurs at runtime when running
    a JPA query created by JPA Criteria Builder.  However, the
    catalyst for this exception is actually set in place at
    Criteria Builder initialization
    (EntityManagerFactory.getCriteriaBuilder()), that is, when a
    user calls 'getCriteriaBuilder' as the very first operation
    after creating the EntityManagerFactory.  However, the time of
    the Criteria Builder initialization is not the entire cause of
    the exception, the issue will only surface when a query is
    run against a very specific set of data in the database.
    While the exact scenario is far too complex and technical to
    properly describe here, suffice it to say that, as mentioned,
    the issue comes down to the following three things happening:
    1) the Criterial Builder is initialized at a specific time
    2) a query is run which was built by Criteria Builder, and
    3) specific data exists in the database.
    

Problem conclusion

  • With this fix, code has been added to OpenJPA to properly
    synchronize Criteria Builder code to avoid the narrow window
    of time where this issue can occur.
    
    The fix for this APAR is currently targeted for
    inclusion in Service Level (Fix Pack)
    8.5.5.5 of WebSphere Application Server version 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

    PI26049

  • Reported component name

    WEBSPHERE APP S

  • Reported component ID

    5724J0800

  • Reported release

    850

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt / Xsystem

  • Submitted date

    2014-09-18

  • Closed date

    2015-01-12

  • Last modified date

    2015-01-12

  • 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

    WEBSPHERE APP S

  • Fixed component ID

    5724J0800

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

Document Information

Modified date:
28 April 2022