Search code examples
javajpaejb-3.0toplink-essentials

Toplink Exception, what's wrong?


I've got an exception when I generate this EJB SQL Statement.

    Exception Description: Syntax error parsing the query [SELECT h FROM Busmodul h WHERE LOWER(h.modulNummer) LIKE :modulnummer AND h.einbauort.id = :einbauort_fk AND h.plattform.id = :plattform_fk ORDER BY TRIM(TRAILING '-' FROM CONCAT('0', h.modulNummer))], line 1, column 150: syntax error at [TRIM].
Internal Exception: line 1:150: expecting IDENT, found 'TRIM'

What's the meaning of IDENT. Any Ideas what I am doing wrong?


Solution

  • Your ORDER BY clause is not valid, you can't order on the values or objects for values or objects not returned by the SELECT clause (see chapter 4.9 ORDER BY Clause of the EJB 3.0 JPA specification).

    BTW, I couldn't find any mention of the use of SQL functions and aggregate functions in the ORDER BY clause in the Query Language chapter of the EJB 3.0 specification so I don't know if this is supported.