Hibernate HQL查询:如何将Collection设置为Query的命名参数? [英] Hibernate HQL Query : How to set a Collection as a named parameter of a Query?
本文介绍了Hibernate HQL查询:如何将Collection设置为Query的命名参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
给出以下HQL查询:
FROM
Foo
WHERE
Id = :id AND
Bar IN(:barList)
我设置了 :id
使用Query对象的 setInteger()
方法。
我想使用 List 设置
:barList
>的对象,但看着Hibernate的文档和方法列表我看不出明显的选择使用。任何想法?
Query.setParameterList()
, Javadoc here 。 有四种选择。
Given the following HQL Query:
FROM
Foo
WHERE
Id = :id AND
Bar IN (:barList)
I set :id
using the Query object's setInteger()
method.
I would like to set :barList
using a List
of objects, but looking at the Hibernate documentation and list of methods I cannot see an obvious choice of which to use. Any ideas?
解决方案
Use Query.setParameterList()
, Javadoc here.
There are four variants to pick from.
这篇关于Hibernate HQL查询:如何将Collection设置为Query的命名参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文