IBM Support

PH01681: CASE THEN AND ELSE SCALAR EXPRESSION CONSTANTS SHOULD NOT BE CASTED TO CASE OPERAND TYPE

Subscribe to this APAR

By subscribing, you receive periodic emails alerting you to the status of the APAR, along with a link to the fix after it becomes available. You can track this item individually or track all items by product.

Notify me when this APAR changes.

Notify me when an APAR for this component changes.

APAR status

  • Closed as program error.

Error description

  • Given a JPQL query utilizing a CASE expression, Eclipselink
    JPQL processing can inappropriately force-typecast the
    THEN/ELSE scalar_expressions to the CASE's case_operation
    type.
    The incompatible typecasting can can lead to a failure.
    

Local fix

  • N/A
    

Problem summary

  • ****************************************************************
    * USERS AFFECTED:  All users of IBM WebSphere Application      *
    *                  Server Liberty - Java Persistence APA - JPA *
    *                  2.1 & EclipseLink                           *
    ****************************************************************
    * PROBLEM DESCRIPTION: EclipseLink throws an exception when    *
    *                      parsing a Query containing a CASE       *
    *                      function with an operand                *
    ****************************************************************
    * RECOMMENDATION:                                              *
    ****************************************************************
    The following sample code demonstrates how an application would
    encounter this exception:
    
    Query:
    TypedQuery<EntityTbl01> query = em.createQuery(""
        + "SELECT t FROM EntityTbl01 t "
        + "WHERE t.itemString1 = ( "
            + "CASE t.itemInteger1 "
                + "WHEN 1000 THEN '047010' "
                + "WHEN 100 THEN '023010' "
                + "ELSE '033020' "
            + "END )", EntityTbl01.class);
    
    Entity:
    @Entity
    @Table(name="SIMPLE_TBL01")
    public class EntityTbl01 implements Serializable {
        @Column(name="ITEM_STRING1")
        private String itemString1;
    
        @Column(name="ITEM_INTEGER1")
        private Integer itemInteger1;
    }
    
    Notice that the query contains a CASE function with an operand
    't.itemInteger1'. According to the JPA specification, Section
    4.8.6, the result of the CASE function should be the product of
    the THEN and ELSE expressions. However, EclipseLink is
    attempting to use the operand as the return type. As a result,
    the following exception is thrown:
    
    java.sql.SQLSyntaxErrorException: Comparisons between 'VARCHAR
    (UCS_BASIC)' and 'INTEGER' are not supported. Types must be
    comparable. String types must also have matching collation. If
    collation does not match, a possible solution is to cast
    operands to force them to the default collation (e.g. SELECT
    tablename FROM sys.systables WHERE CAST(tablename AS
    VARCHAR(128)) = 'T1')
    	at
    org.apache.derby.client.am.SQLExceptionFactory.getSQLException(U
    nknown Source)
    	at
    org.apache.derby.client.am.SqlException.getSQLException(Unknown
    Source)
    	at
    org.apache.derby.client.am.ClientStatement.executeQuery(Unknown
    Source)
    	at
    org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor
    .executeSelect(DatabaseAccessor.java:1007)
    	at
    org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor
    .basicExecuteCall(DatabaseAccessor.java:644)
    

Problem conclusion

Temporary fix

Comments

APAR Information

  • APAR number

    PH01681

  • Reported component name

    LIBERTY PROFILE

  • Reported component ID

    5724J0814

  • Reported release

    CD0

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt / Xsystem

  • Submitted date

    2018-08-13

  • Closed date

    2018-10-16

  • Last modified date

    2018-10-16

  • 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

    LIBERTY PROFILE

  • Fixed component ID

    5724J0814

Applicable component levels



Document information

More support for: WebSphere Application Server

Software version: CD0

Reference #: PH01681

Modified date: 16 October 2018


Translate this page: