IBM Support

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

Fixes are available

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
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
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

Subscribe

You can track all active APARs for this component.

 

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

  • RCD0 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":"CD0","Line of Business":{"code":"LOB36","label":"IBM Automation"}}]

Document Information

Modified date:
17 October 2021