I created a NamedQuery that looks like this:
@NamedQuery(name = "EventLog.viewDatesInclude", query = "SELECT el FROM EventLog el WHERE el.timeMark >= :dateFrom AND " + "el.timeMark <= :dateTo AND " + "el.name IN (:inclList)")
What I want to do is to specify a parameter: inclList with a list of elements instead of a single element. For example, if I have a new List<String>() { "a", "b", "c" } , how can I get this in the parameter: inclList? This allows me to codify a single string. For example:
setParameter("inclList", "a") // works setParameter("inclList", "a, b") // does not work setParameter("inclList", "'a', 'b'") // does not work setParameter("inclList", list) // throws an exception
I know that I can just build a string and build the whole query out of it, but I wanted to avoid the overhead. Is there a better way to do this?
Related question: if the List is very large, is there a good way to build such a query?
java jpa jpql
AlanObject Dec 07 '10 at 16:12 2010-12-07 16:12
source share