java - How to set collection items for in-clause in jpql? -


is there possiblity in jpa 2.0 set collection in-clause in jpql-query? (i'm using eclipselink)

the next example fails:

typedquery<person> q = em.createquery("select p person p p.name in (?1)", person.class);  list<string> names = arrays.aslist(new string[] { "bill gates", "steve jobs" }); // fails q.setparameter(1, names);  list<person> persons = q.getresultlist(); (person p: persons) {     system.out.println(p.getname()); } 

is there way it?

here jpa 2.0 specification says in expressions:

4.6.9 in expressions

the syntax use of comparison operator [not] in in conditional expression follows:

in_expression ::=     {state_field_path_expression | type_discriminator} [not] in         { ( in_item {, in_item}* ) | (subquery) | collection_valued_input_parameter } in_item ::= literal | single_valued_input_parameter 

...

so according specification, correct syntax when passing collection_valued_input_parameter without parenthesis:

select p person p p.name in ?1 

and works eclipselink.


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -

PostgreSQL 9.x - pg_read_binary_file & inserting files into bytea -