有一个关于Hibernate配置的问题

我是使用Annontation mapping的,
有一个父类叫TeacherRefBase,定义如下:
@MappedSuperclass
class TeacherRefBase implements Serializable {

    ..........
   
    @Id
    @GeneratedValue(strategy=GenerationType.AUTO)
    public long getId() {
        return id;
    }

    @ManyToOne(targetEntity=Teacher.class)
    @JoinColumn(name="teacherId")
    @NotNull
    public Teacher getTeacher() {
        return teacher;
    }
}
这里把TeacherRefBase join到 Teacher。
然后在来一个

@MappedSuperclass
class TeacherRef implements Serializable {

    ..........
   
    public String getName() {
        return name;
    }
   
    public int getAge() {
        return age;
    }

    @OneToOne(targetEntity=Teacher.class)
    @JoinColumn(name="teacherId")
    @NotNull
    public Teacher getTeacher() {
        return teacher;
    }
}

最后来个
@Entity
@Table(name="WorkHistory")
public class WorkHistory extends TeacherRef {
    
    ........

}

这个时候启动的时候就报错
Duplicate property mapping of teacher found in WorkHistory

请问这个问题 怎么解决?

你可能感兴趣的:(Hibernate,DWR)