Use of @OneToMany or @ManyToMany targeting an unmapped class

昨天,在做一个项目的时候,发现了报出了这个问题:Use of @OneToMany or @ManyToMany targeting an unmapped class

然后自己找了很久发现,原来是配置文件<applicationContext.xml>出了问题,没有声明这个类:

<property name="annotatedClasses">
<list>
<value>com.itcast.oa.domain.Role</value>
<value>com.itcast.oa.domain.Department</value>
<value>com.itcast.oa.domain.User</value>
</list>
</property>

 

其次还报出的了这个问题:Associations marked as mappedBy must not define database mappings like @JoinTable or @JoinColumn

 一查才记起使用了(mappedBy)配置后是没办法和@JoinColumn或@JoinTable一起使用,用了这么久有点忘了这个:

@OneToMany(mappedBy="dept")
@JoinColumn//无法使用,会报错
public Set<User> getUsers() {
return users;
}

posted @ 2014-04-10 12:29  Yhiloon  阅读(2135)  评论(0编辑  收藏  举报