Reputation: 3
I am trying to create a custom query, but my select returns empty results.
this.getSession()
.createQuery("FROM com.dummy.tralala.MyClass AS test where test.name in (:labels)")
.setParameter("labels",myLabels).list()
;
what is wrong?
when I do it like this
.createQuery("FROM com.dummy.tralala.MyClass AS test where test.name in ("+myLabelsString+")").list()
then it is working just fine.
Upvotes: 0
Views: 58
Reputation: 611
If you want to use a list of parameters, use the method setParameterList
this.getSession()
.createQuery("FROM com.dummy.tralala.MyClass AS settings where settings.name in (:labels)")
.setParameterList("labels",myLabels).list();
myLabels could be a Collection or an array.
Upvotes: 1