我想问一下如何使用带有List属性的class的exampleMatcher.让我们假设,我们有一个可以同时拥有多个角色的用户.我希望从DB获得具有用户角色的所有用户
实体
@Entity(name = "UserEntity")
public class User {
Private Long id;
private String name;
private String surname;
@OneToOne(cascade = CascadeType.ALL)
@JoinColumn
private Address address;
@ManyToMany(cascade = CascadeType.MERGE, fetch = FetchType.EAGER)
@JoinColumn
private List<UserRole> roles;
}
@Entity
public class UserRole {
private Long id;
private String name;
}
Run Code Online (Sandbox Code Playgroud)
我发送一个带有一些属性的User类到getExampleEntity.我正在尝试从UI发送所选角色的列表.
控制器中的功能
@Override
protected User getExampleEntity() {
User clonedUser = new User();
List<UserRole> selectedRole = new ArrayList<>();
// this cycle just find and add all roles in db based on selection from …Run Code Online (Sandbox Code Playgroud)