hibernate中@ManyToMany中的疑问
roleGroup表
出现以下错误,求大大们看看
@Table(name="news_roleGroup")
public class RoleGroup {
private int id; //角色组ID(主键)
private String roleGroupName; //角色组名字(唯一)
private Set<Permission> permissiones=new HashSet<Permission>(); //角色组所包含的权限
@Column(name="roleGroup_id")
@Id
@GeneratedValue(generator="system-uuid")
@GenericGenerator(name="system-uuid",strategy="uuid")
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
@Column(name="roleGrope_name",length=15,nullable=false,unique=true)
public String getRoleGroupName() {
return roleGroupName;
}
public void setRoleGroupName(String roleGroupName) {
this.roleGroupName = roleGroupName;
}
@ManyToMany(
targetEntity=com.webnews.entity.Permission.class,
mappedBy="roleGroups", 不知道这个mappedBy能不能写
cascade=CascadeType.ALL,
fetch=FetchType.LAZY)
public Set<Permission> getPermissiones() {
return permissiones;
}
public void setPermissiones(Set<Permission> permissiones) {
permission表
[code=java]
@Entity
@Table(name="news_permission")
public class Permission {
private int id; //权限ID(主键)
private String permissionName; //权限名字(唯一)
private Set<RoleGroup> roleGroups=new HashSet<RoleGroup>(); //权限所属角色组
@Column(name="permission_id")
@Id
@GeneratedValue(generator="system-uuid")
@GenericGenerator(name="system-uuid",strategy="uuid")
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
@Column(name="permission_name",length=15,nullable=false,unique=true)
public String getPermissionName() {
return permissionName;
}
public void setPermissionName(String permissionName) {
this.permissionName = permissionName;
}
@ManyToMany(
targetEntity=com.webnews.entity.RoleGroup.class,
cascade=CascadeType.ALL,
fetch=FetchType.LAZY)
@JoinTable(
name="permission_roleGroup",
joinColumns={@JoinColumn(name="permission_id")},
inverseJoinColumns={@JoinColumn(name="roleGroup_id")}
)
public Set<RoleGroup> getRoleGroup() {
return roleGroups;
}
public void setRoleGroup(Set<RoleGroup> roleGroups) {
this.roleGroups = roleGroups;
}
出现以下错误,求大大们看看
...全文
相关推荐
hibernate多对多关系
资源我就不多多介绍了,代码是我自己亲手写的,有问题和我联系或给我写评论。
Hibernate关联关系疑问
NULL 博文链接:https://dreamzhong.iteye.com/blog/1218841
CH4Hibernate2,一对多,多对一,多对多实现增删改查
解压导入到你的Myeclipse或者eclipse,更改路径,加入架包
Hibernate 中的多对多的关系:
博文链接:https://shazi.iteye.com/blog/102946
hibernate多对多单向关联
博文链接:https://shaqiang32.iteye.com/blog/201316


Web 开发
