Possible issue for JPQL IN expression

#1

Possible issue for JPQL IN expression with a set of more than one string literals values in the path expression.


Error:
Exception in thread "main" [ObjectDB 2.3.7_10] SELECT e FROM MyEntity e WHERE e.country IN ('US' ==> , <==  'SP', 'UK')
javax.persistence.PersistenceException
Unexpected query token ',' (closing ')' is missing) (error 752)
(position 49) at com.objectdb.jpa.JpaQuery.getResultList(JpaQuery.java:695)
at MyTestCase.main(MyTestCase.java:27)
Caused by: com.objectdb.o.UserException: Unexpected query token ',' (closing ')' is missing)

 

Thanks

#2

This is one of the few elements of JPQL that are not implemented yet.

The workaround is to use a parameter:

SELECT e FROM MyEntity e WHERE e.country IN :countries

and send a collection of strings as an argument when executing the query. Using a parameter is also more efficient because the query can be compiled once and run multiple times with different string collections.

ObjectDB Support

Reply