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.
@ManyToMany
Task class
Try from Task where To.Id IN (:userid)
from Task where To.Id IN (:userid)
The point is that To is a collection. The most usual way to filter by criteria on collection elements is to join it first:
To
select distinct t from Task t join t.To tto where tto.Id = :userid