0

I create a query like this in JPA (EclipseLink)

Query selectQuery = ... and SUBSTR(FOO, 0, 1) IN (?1)

or

Query selectQuery = ... and SUBSTR(FOO, 0, 1) IN ?1

I set a parameter like this:

selectQuery.setParameter(1, Arrays.asList(new String[] { "T" }));

However it is telling me invalid column type

When I change my query to this:

Query selectQuery = ... and SUBSTR(FOO, 0, 1) IN ('T')

it works as expected.

Did I miss anything?

matthias
  • 1,712
  • 16
  • 39

2 Answers2

0

Duplicate. The answer, anyway, is to use SUBSTR(FOO, 0, 1) IN ?1 without the parantheses.

Michael Piefel
  • 16,556
  • 7
  • 75
  • 104
0

You are passing a list as a parameter, thus you should use the setParameterList method:

selectQuery.setParameterList(1, Arrays.asList(new String[] { "T" })); 
Maciej Kowalski
  • 23,799
  • 10
  • 49
  • 59