openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From HaricotBean <>
Subject OpenJPA1.2.2 - NativeQuery - IN clause
Date Mon, 31 Aug 2009 22:28:28 GMT

Which type is NativeQuery expecting for a parameter that maps to a IN clause? 
Through trial and error I found that Collections cause an error to be throw
and Arrays execute but return no results.  However if I pass a single String
value it works...

@NamedNativeQuery(name = "Entity.mostRefersType", query = "select
count(e.eid), e.* from Entity e, Property p where e.eid=p.refersTo and
p.type IN ( ?1 ) group by e.eid order by count(e.eid) desc;",
resultSetMapping = "MostUsedResults"),

Surprisingly (to me at least) the following has been my observation:

query.setParameter(1, "A"); // successful
query.setParameter(1, {"A","B"}); // executes but fails to match
Collection<String> set = new ArraySet(); set.add("A)";
query.setParameter(1, set); // throws invalid parameter exception on execute

Does anyone have any clues as to what the right approach might be to use a
named query. The alternative is to build a string representation of the sql
statement but I would like to find the answer.

Regards ...

View this message in context:
Sent from the OpenJPA Users mailing list archive at

View raw message