hibernate query for list in where clause

后端 未结 2 742
醉酒成梦
醉酒成梦 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: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
    

提交回复
热议问题