Assuming we have a query like this one where the end parenthesis does not have a matching start parenthesis:
{code:java} session.createQuery( "select a from Product a " + "where " + "coalesce(a.description, :description) = :description)", Product.class) .setParameter( "description", "desc" ) .getResultList(); {code}
The end parenthesis is discarded instead of throwing an exception:
{code: sql} select product0_.productId as productI1_35_, product0_.description as descript2_35_, product0_.cost as cost3_35_, product0_.numberAvailable as numberAv4_35_ from Product product0_ where coalesce(product0_.description, ?)=? {code}
Now, this can lead to very weird situations where the following clauses are simply discarded. So, i you have an ORDER BY clause after the extra parenthesis:
{code: java} session.createQuery( " select a from Product a " + "where " + "coalesce(a.description, :description) = :description ) " + "order by a.description ", Product.class) .setParameter( "description", "desc" ) .getResultList(); {code}
The ORDER BY vanishes from the SQL statement:
{code:sql} select product0_.productId as productI1_35_, product0_.description as descript2_35_, product0_.cost as cost3_35_, product0_.numberAvailable as numberAv4_35_ from Product product0_ where coalesce(product0_.description, ?)=? {code}
|
|