hibernate query for list in where clause

后端 未结 2 731
醉酒成梦
醉酒成梦 2020-12-12 04:47

I\'ve @ManyToMany mapped classes in spring application I want to get all of the tasks that I\'ve assigned to a particular user by id.

Task class

相关标签:
2条回答
  • 2020-12-12 05:11

    Try from Task where To.Id IN (:userid)

    0 讨论(0)
  • 2020-12-12 05:12

    The point is that To is a collection. The most usual way to filter by criteria on collection elements is to join it first:

    select distinct t from Task t join t.To tto where tto.Id = :userid
    
    0 讨论(0)
提交回复
热议问题