Hello!
I often use queries like
Code:
FROM Person person WHERE person.name IN ('joe', 'frank', 'andy')
where the names are retrieved from a collection or array. Currently i use a method to quote the strings and insert "," in between, so i construct the string "'joe', 'frank', 'andy'" manually.
Is there any simpler way to do this (without using the criteria api, just by plain written hql)? The criteria api supports
Code:
Expression.in("name", new String[] {"joe", "frank", "andy"} );
I thought of something like
Code:
hibernateTemplate.find("FROM Person person WHERE person.name IN ?", new String[] {"joe", "frank", "andy"} );
(which actually does not work, but causes an error because hibernate is looking for a second and third string parameter in the query)
Is there any way to do this?
I found elements() in "Hibernate in Action", but it seems elements() can not be used on Collections or Array given as parameters.
Thanks for your help!
Sebastian