IBM Support

PH36841: ECLIPSELINK CRITERIABUILDER TRIM FUNCTION CREATES INCORRECT SQL

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

  • EclipseLink generates incorrect SQL from CriteriaBuilder for
    the &#180;CriteriaBuilder.trim(char t, Expression<String>
    x)&#180; function. It is important to note that this may not be
    failing as some databases will not fail attempting to execute
    this SQL, but the query is very wrong and cannot return the
    expected result.
    
    Example:
    &#180;&#180;&#180;
        CriteriaBuilder cb = em.getCriteriaBuilder();
        CriteriaQuery<Object[]> cquery =
    cb.createQuery(Object[].class);
        Root<SimpleEntity> root = cquery.from(SimpleEntity.class);
        cquery.multiselect(cb.trim(cb.literal('A'),
    cb.literal("AAHELLO WORDAAAAA")));
        cquery.where(cb.equal(root.get(SimpleEntity_.strVal1),
    cb.literal("HELLO")));
    
        Query query = em.createQuery(cquery).getResultList();
    &#180;&#180;&#180;
    
    Example SQL:
    &#180;&#180;&#180;
        SELECT TRIM('AAHELLO WORDAAAAA' FROM 'AAHELLO WORDAAAAA')
    FROM SIMPLEENTITY WHERE (STRVAL1 = 'HELLO')
    &#180;&#180;&#180;
    

Local fix

Problem summary

  • ****************************************************************
    * USERS AFFECTED:  All users of IBM WebSphere Application      *
    *                  Server - Java Persistence API - JPA 2.1 &   *
    *                  EclipseLink                                 *
    ****************************************************************
    * PROBLEM DESCRIPTION: EclipseLink generates incorrect SQL     *
    *                      from CriteriaBuilder                    *
    *                      for &#180;CriteriaBuilder.trim()&#180; functions  *
    ****************************************************************
    * RECOMMENDATION:                                              *
    ****************************************************************
    Example:
    &#180;&#180;&#180;
    CriteriaBuilder cb = em.getCriteriaBuilder();
    CriteriaQuery<Object[]> cquery =
    cb.createQuery(Object[].class);
    Root<SimpleEntity> root = cquery.from(SimpleEntity.class);
    cquery.multiselect(cb.trim(cb.literal('A'),
    cb.literal("AAHELLO WORDAAAAA")));
    cquery.where(cb.equal(root.get(SimpleEntity_.strVal1),
    cb.literal("HELLO")));
    Query query = em.createQuery(cquery).getResultList();
    &#180;&#180;&#180;
    Example SQL:
    &#180;&#180;&#180;
    SELECT TRIM('AAHELLO WORDAAAAA' FROM 'AAHELLO WORDAAAAA')
    FROM SIMPLEENTITY WHERE (STRVAL1 = 'HELLO')
    &#180;&#180;&#180;
    

Problem conclusion

Temporary fix

Comments

APAR Information

  • APAR number

    PH36841

  • Reported component name

    WEBSPHERE APP S

  • Reported component ID

    5724J0800

  • Reported release

    900

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt / Xsystem

  • Submitted date

    2021-04-29

  • Closed date

    2021-07-07

  • Last modified date

    2021-07-07

  • 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

  • R900 PSY

       UP

[{"Line of Business":{"code":"LOB36","label":"IBM Automation"},"Business Unit":{"code":"BU053","label":"Cloud \u0026 Data Platform"},"Product":{"code":"SSEQTP","label":"WebSphere Application Server"},"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"900"}]

Document Information

Modified date:
16 July 2021