Java Question

Hibernate - where clause any with collection as a named parameter query

I'm wondering if is possible to make this kind of evaluation with collections like the query isn't working in my project at a class named query as follow:

@NamedQueries(value = {
name = "Foo.getBarList",
query = "select f from Foo f where (:barlist is null or in (:barslist)) " )})

from this both post:

FROM Foo WHERE Id = :id AND (:barlist is null or Bar in (:barlist))

JPA where clause any

Hibernate HQL Query : How to set a Collection as a named parameter of a Query?

I guess the problem was the id in query so I remove and the error stop, just change this "select f from Foo f where (:barlist is null or f.barlist in (:barslist)) "

Answer Source

instead of in HQL you can check

    //query=FROM Foo WHERE Id = :id
   //query=FROM Foo WHERE Id = :id AND Bar in :barlist
   // query.setParameterList(:barlist",<list object>)