RESTFul Web サービスの作成中に、NetBeans 7.4 によって生成された Entity クラス コードがあります。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;
}
hibernate.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>
hibernate.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>