Remove the elements part of your query:
<query name="Nutrient.findNutrients1"> <![CDATA[from Nutrient as nutrient where nutrient.id in (:ids)]]> </query>
And call it like this:
List<Long> vals = Arrays.asList(1L, 2L); Query q = session.getNamedQuery("Nutrient.findNutrients1"); q.setParameterList("ids", vals); List<Nutrient> result = q.list();
source share