129 words

Possible issue for JPQL IN expression

#1
2012-04-17 16:40

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

eurojet
eurojet's picture
Joined on 2012-04-12
User Post #2
#2
2012-04-17 21:35

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
ObjectDB - Fast Object Database for Java (JPA/JDO)
support
support's picture
Joined on 2010-05-03
User Post #1,017

Post Reply

Please read carefully the posting instructions - before posting to the ObjectDB website.

  • You may have to disable pop up blocking in order to use the toolbar (e.g. in Chrome).
  • Use ctrl + right click to open the browser context menu in the editing area (e.g. for using a browser spell checker).
  • To insert formatted lines (e.g. Java code, stack trace) - select a style in the toolbar and then insert the text in the new created block.
  • Avoid overflow of published source code examples by breaking long lines.
  • You may mark in paragraph code words (e.g. class names) with the code style (can be applied by ctrl + D).
  • Long stack traces (> 50 lines) and complex source examples (> 100 lines) should be posted as attachments.
Attachments:
Maximum file size: 32 MB
Cancel