2009-10-01 77 views
2

我遇到了命名查詢參數的問題。我的查詢如下:Hibernate命名查詢參數

<sql-query name="getCustomer"> 
<![CDATA[ 
    select * from customer where customerId=:custId and billId in (:billIdList) 
]]> 
</sql-query> 

我設置的所有參數,但有問題:billIdList每當我設置這個參數,我得到客戶的空單。我的:billIdList是字符串形式,例如:5,6,7,9。 DB中的數據也具有上述值。當我在程序中自己寫查詢 時,它工作正常。

請幫幫我。

回答

1

對於有多個值參數,你需要使用Hibernate的Query接口的setParameterList()方法:

query.setParameterList("billIdList", new int[] {5,6,7,9});