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
謝謝,這有助於! –