Spring Data JPA: query ManyToMany
2022-08-31 19:45:00
我有实体和User
Test
@Entity
public class User {
private Long id;
private String userName;
}
@Entity
public class Test {
private Long id;
@ManyToMany
private Set<User> users;
}
我可以按用户实体获取所有测试:
public interface TestRepository extends JpaRepository<EventSettings, Long> {
List<Test> findAllByUsers(User user);
}
但是,我可以使用哪个查询来查找所有测试?userName