Search code examples
jpaeclipselinkjpa-2.0criteria-api

JPA Criteria API causing missing right parenthesis error


I have the following Expression to concatenate two columns

Expression<String> stringConcat = 
criteriaBuilder.concat(criteriaBuilder.concat(rootPr.get(ProductList_.prodDesc), " # "), 
rootEmp.get(ProductEmp_.empNo));

and it used in CriteriQuery in the followng manner,

criteriaQuery.multiselect(root.get(ProductCatalogue_.userId), 
root.get(ProductCatalogue_.productList),criteriaBuilder.selectCase()
.when(criteriaBuilder.equal(root.get(ProductCatalogue_.prodId),"ZCX"), stringConcat)
.otherwise(rootPr.get(ProductList_.prodDesc)));

However when SQL is generated, it is throwing error

missing right parenthesis

because in if else part of SQL has a question mark as it is expecting a parameter

THEN (t0.prodDesc = ?)

How to resolve this problem?


Solution

  • This is an EclipseLink bug, that was fixed in version 2.4.2. Upgrade to a newer version, and it will work (tested on EclipseLink 2.5.2).