代码之家  ›  专栏  ›  技术社区  ›  jaxb

Hibernate命名查询参数

  •  2
  • jaxb  · 技术社区  · 15 年前

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

    我正在设置所有参数,但在:billIdList中有问题每当我设置此参数时,我都会得到一个空的客户列表。My:billIdList采用字符串形式,例如:5,6,7,9。数据库中的数据也包含上述值。当我编写查询时,它工作得很好 在程序中它自己。

    请帮帮我。

    1 回复  |  直到 15 年前
        1
  •  1
  •   ChssPly76    15 年前

    对于具有多个值的参数,需要使用 setParameterList() Hibernate方法 Query 接口:

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