Hibernate named query parameter

I have a problem with the named query parameter. My request is as follows:

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

      

I am setting all the parameters, but I have a problem with: billIdList whenever I set this parameter, I get an empty list of clients. My: billIdList is in string form, for example: 5,6,7,9. There is also data in the database with the above values. It works great when I write the request in the program itself.

Please help me.

+2


source to share


1 answer


For parameters with more than one value, you need to use the setParameterList()

Hibernate interface method Query

:



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

      

+1


source







All Articles