Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/84.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql 如何将值列表作为参数设置到hibernate查询中?_Sql_Hibernate_Jpa - Fatal编程技术网

Sql 如何将值列表作为参数设置到hibernate查询中?

Sql 如何将值列表作为参数设置到hibernate查询中?,sql,hibernate,jpa,Sql,Hibernate,Jpa,例如,我有这个查询 select cat from Cat cat where cat.id in :ids 我想将ID设置为list(1,2,3,4,5,6,17,19) 这个代码不起作用 session.createQuery("select cat from Cat cat where cat.id in :ids") .setParameter("ids", new Long[]{1,2,3,4,5}) 因此,我希望在(1,2,3,4)中使用类似于id的SQL查询使

例如,我有这个查询

 select cat from Cat cat where cat.id in :ids 
我想将ID设置为list(1,2,3,4,5,6,17,19)

这个代码不起作用

session.createQuery("select cat from Cat cat where cat.id in :ids")
       .setParameter("ids", new Long[]{1,2,3,4,5})
因此,我希望在(1,2,3,4)中使用类似于
id的SQL查询
使用。您还必须在列表参数周围加上括号

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

setParameterList
是在较新的hibernate中创建的。我们怎么把这个传进来?我尝试使用
setparameter
,但没有得到正确的行为。。。