Spring Data JPA Specification with MayToMany relation
0 I'm trying to use Specification to build a search criteria with Spring Data JPA. I have 2 entities @Entity public class User { @Id private Long userId; @ManyToMany @JoinColumn(name="locationId") @JsonIgnore private List<Location> locations; //getters and setters And Location public class Location { @Id private long locationId; @ManyToMany(fetch = FetchType.LAZY, cascade = CascadeType.PERSIST, CascadeType.REMOVE, CascadeType.DETACH, CascadeType.REFRESH , mappedBy = "locations") @JsonIgnore private List<User> users; //getters and setters Now I would like to find all users with a given list of locations, so I'm trying to build the predicate. My problem is getting the relation table between the 2 entities... I'm trying in this way Root<Location> second = query.from(Location.class); Expression<Collection<Root>> userLocations = second.get("users"); return builder.and(builder.isMember(root, u...