标签:
假如是用户表与权限表的多对多,其中用户表中的注解配置:
// 权限
@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@JoinTable(name = "user_permission", joinColumns = @JoinColumn(name = "user_id"), inverseJoinColumns = @JoinColumn(name = "permission_id"))
public List<Permission> permissionList;
权限表中的注解配置:
//用户
@ManyToMany(cascade = CascadeType.ALL, mappedBy = "permissionList", fetch = FetchType.LAZY)
public List<User> ownerList;
在进行保存时:通过保存User表来查询Permission权限表。
标签:
原文地址:http://www.cnblogs.com/xunfang123/p/4243381.html