在创建 RESTFul Web 服务时,我有 NetBeans 7.4 生成的实体类代码。当我测试 web 服务时,我得到以下异常
The target entity of the relationship attribute [emps] on the class
[class test.Dept] cannot be determined. When not using generics, ensure
the target entity is defined on the relationship mapping.
企业实体
@Entity
@Table(name="EMP"
,schema="SCOTT"
)@XmlRootElement
public class Emp implements java.io.Serializable {
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name="DEPTNO")
public Dept getDept() {
return this.dept;
}
部门实体
@Entity
@Table(name="DEPT"
,schema="SCOTT"
)@XmlRootElement
public class Dept implements java.io.Serializable {
@OneToMany(fetch=FetchType.LAZY, mappedBy="dept")
public Set getEmps() {
return this.emps;
}
休眠.reveng
<?xml version="1.0" encoding="UTF-8"?>
<hibernate-reverse-engineering>
<schema-selection match-schema="SCOTT"/>
<table-filter match-name="EMP"/>
<table-filter match-name="DEPT"/>
</hibernate-reverse-engineering>
休眠.cfg
<session-factory>
<property name="hibernate.dialect">org.hibernate.dialect.OracleDialect</property>
<property
name="hibernate.connection.driver_class">oracle.jdbc.OracleDriver</property>
<mapping class="test.Emp"/>
<mapping class="test.Dept"/>
</session-factory>