簡體   English   中英

Hibernate命名查詢參數

[英]Hibernate named query parameter

我有命名查詢參數的問題。 我的查詢如下:

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

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

請幫我。

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

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM