How to set list of values as parameter into hibernate query?

后端 未结 1 1261
青春惊慌失措
青春惊慌失措 2021-02-03 23:05

For example, I have this query

 select cat from Cat cat where cat.id in :ids 

and I want to set ids to list (1,2,3,4,5,6,17,19).

This

相关标签:
1条回答
  • 2021-02-03 23:30

    Use setParameterList(). You'll also have to put parenthesis around the list param.

    session.createQuery("select cat from Cat cat where cat.id in (:ids)").setParameterList("ids", new Long[]{1,2,3,4,5})
    
    0 讨论(0)
提交回复
热议问题