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
Simple, Fast SQL Queries for Flat Files
Iterate Through a List of Strings in SQL Server
Running a SQLite3 Script from Command Line
How to Replace Blank (Null ) Values with 0 for All Records
How to Use Max() on a Subquery Result
How to Best Handle the Storage of Historical Data
SQL Query for Courses Enrolment on Moodle
Efficient Time Series Querying in Postgres
How to Increment Value in Postgres Update Statement on JSON Key
How to Set a Datetime Variable in SQL Server 2008
Oracle Date Datatype, Transformed to 'Yyyy-Mm-Dd Hh24:Mi:Ss Tmz' Through SQL
Query to Convert from Datetime to Date MySQL
How to Get the Employees with Their Managers
Acts-As-Taggable-On Find All Tags by Context
Any Disadvantages to Bit Flags in Database Columns
How to Concat_Ws Multiple Fields and Remove Duplicate Separators for Empty Slots
Optimising a Select Query That Runs Slow on Oracle Which Runs Quickly on SQL Server