Hibernate中manytomany的问题

www203 www203 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
做过的指点一下,没做过路过的给人人场,谢谢大家了


是权限,权限组之间的多对多的关系,我用如下方法关联(关联表是: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
...全文
评论 3
收藏 已收藏
分享
返回顶部
www203
Java EE 67,535 成员 225,843 内容