0
我试图与多个创建HQL查询其中相同休眠HQL查询
result = sessionFactory.getCurrentSession().createQuery("from County where " + [0].property + "=?"+","+ c[1].property + "=?")
.setParameter paramteres(0,C [0]。价值)
.setParameter(1,C [1]。价值).LIST();的
,而不是做这个,我想创建一个查询,可以处理任何数量的paramters像
for(Params c:parms){`enter code here`
queryString+= c.property +" = "+c.value+",";
}
result = (State) sessionFactory.getCurrentSession()
.createQuery("from County where " +queryString)
.list().get(0);
有查询看起来是正确的,但它说:“不能执行查询”
a)使用多个pams而不是固定大小b)它应该是queryString c)即使我只有一个参数用于上述代码失败的地方! –
@ user1827614看到我的编辑 – beder
谢谢,这有助于! –