Hibernate中manytomany的问题
做过的指点一下,没做过路过的给人人场,谢谢大家了
是权限,权限组之间的多对多的关系,我用如下方法关联(关联表是:tt_limit_to_group,里面用字段:limit_id和group_id来进行关联):
在LimitGroupPoJo类中:
@ManyToMany(cascade = { CascadeType.PERSIST, CascadeType.MERGE },
fetch = FetchType.LAZY)
@JoinTable(name="tt_limit_to_group", joinColumns={@JoinColumn(name="group_id")},
inverseJoinColumns={@JoinColumn(name="limit_id")})
public Set<LimitPoJo> getLimits() {
return limits;
}
在LimitPoJo类中:
@ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE },
fetch = FetchType.LAZY, mappedBy="limits")
public Set<LimitGroupPoJo> getGroups() {
return groups;
}
如果不要这个多对多的关联的信息则tomcat启动一切正常
加了这个多对多的关系则报如下的错误
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.MappingException: Could not determine type for: java.util.Set, at table: tt_limit_group, for columns: [org.hibernate.mapping.Column(limits)]
Caused by: org.hibernate.MappingException: Could not determine type for: java.util.Set, at table: tt_limit_group, for columns: [org.hibernate.mapping.Column(limits)]
Caused by: java.lang.NoClassDefFoundError: org/apache/xerces/impl/dtd/XMLDTDDescription
是权限,权限组之间的多对多的关系,我用如下方法关联(关联表是:tt_limit_to_group,里面用字段:limit_id和group_id来进行关联):
在LimitGroupPoJo类中:
@ManyToMany(cascade = { CascadeType.PERSIST, CascadeType.MERGE },
fetch = FetchType.LAZY)
@JoinTable(name="tt_limit_to_group", joinColumns={@JoinColumn(name="group_id")},
inverseJoinColumns={@JoinColumn(name="limit_id")})
public Set<LimitPoJo> getLimits() {
return limits;
}
在LimitPoJo类中:
@ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE },
fetch = FetchType.LAZY, mappedBy="limits")
public Set<LimitGroupPoJo> getGroups() {
return groups;
}
如果不要这个多对多的关联的信息则tomcat启动一切正常
加了这个多对多的关系则报如下的错误
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.MappingException: Could not determine type for: java.util.Set, at table: tt_limit_group, for columns: [org.hibernate.mapping.Column(limits)]
Caused by: org.hibernate.MappingException: Could not determine type for: java.util.Set, at table: tt_limit_group, for columns: [org.hibernate.mapping.Column(limits)]
Caused by: java.lang.NoClassDefFoundError: org/apache/xerces/impl/dtd/XMLDTDDescription
...全文
相关推荐
manytomany注解模式.rar
manytomany注解模式.rar manytomany注解模式.rar
HIbernate-ManytoMany:HIbernate-ManytoMany 不同实体之间的关系
用于映射多对多关系的 Hibernate 注释
springboot_relationships_manytomany_jointable
springboot_relationships_manytomany_jointable
Hibernate一对多 多对一实例
Hibernate 一对多 多对多 保证代码完整性,能够很好的理解之间的关系。
Hibernate4种多表关系实例
hibernate的四种映射关系,本资源将四种关系以代码形式例举出来,希望能让大家用得上,呵呵


