EJB3 Query + in
I need to use an IN clause like the following SQL
SELECT * FROM tableA WHERE colA in (1, 2,3)
How can I do this in EJBQL?
I tried the following which clearly didn't work:
SELECT tab FROM tableA tab WHERE tab.colA in (:colValues)
then in java i did
query.setParameter("colValues","1,2,3")
which gives me the following exception
org.apache.openjpa.lib.jdbc.ReportingSQLException: ORA-01722: invalid number
0
source to share
2 answers
The problem is what you are using :parameter_name
in the sql snippet and then calling query. setParamter("parameter_name", values)
is expected values
to be of some sort collection
. Try it.
List<Integer> values = new ArrayList<Integer>();
values.add(1);
values.add(2);
values.add(3);
query.setParameter("colValues", values);
+4
source to share