How to Set List of Values as Parameter into Hibernate Query

How to set list of values as parameter into hibernate query?

Use setParameterList(). You'll also have to put parenthesis around the list param.

session.createQuery("select cat from Cat cat where cat.id in (:ids)").setParameterList("ids", new Long[]{1,2,3,4,5})

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

Use Query.setParameterList(), Javadoc here.

There are four variants to pick from.

How to use setParameter in Hibernate

You need to fix the following:

Your search criteria should be pde.serialNumber IN (:serialNumberList)

You need to change the parameter serial number to list and use:

setParameterList("serialNumberList", serialNumberList)

Set array of parameters to hibernate query language

try this one

 query.setParameterList("reportID", new Object[]{"aaa","bbb"});

Passing parameter to HQL

Try

query2.setParameterList("ids", ids);


Related Topics



Leave a reply



Submit