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