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've tryed the following, which obviously failed:
SELECT tab FROM tableA tab WHERE tab.colA in (:colValues)
then in java i did
query.setParameter("colValues","1,2,3")
that gives me the following exception
org.apache.openjpa.lib.jdbc.ReportingSQLException: ORA-01722: invalid number
From stackoverflow
-
It's been a long while since I've done EJBQL, but this should work:
SELECT OBJECT(t) FROM Tab AS t WHERE t.colA IN (:colValues)Also, you may need to set colValues as an array of numbers rather than a string
-
The problem is when you use
:parameter_namein an sql fragment and then callquery. setParamter("parameter_name", values)it is expected thatvaluesshould be some sort ofcollection. Try this.List<Integer> values = new ArrayList<Integer>(); values.add(1); values.add(2); values.add(3); query.setParameter("colValues", values);
0 comments:
Post a Comment