我正在尝试编写一个JPQL,以通过Users
进行过滤来获取包含某些Roles
的{{1}}。
Role.Name
我在jpa存储库中的@Query上尝试了以下内容
public class User
@ManyToMany
@JoinTable(
name = "UsersRoles",
joinColumns = {@JoinColumn(name = "UsersId", referencedColumnName = "UsersId")},
inverseJoinColumns = {@JoinColumn(name = "RolesName", referencedColumnName = "Name")})
@BatchSize(size = 20)
private Set<Role> roles = new HashSet<>();
}
public class Role {
@Id
@Column(name = "Name", length = 50)
private String name;
}
但这不起作用,它会生成如下所示的sql。
SELECT U FROM User U INNER JOIN Role R WHERE R.name = ?1
未添加加入条件。