0
我有一个问题(我不知道这是否是可能的)丝毫的关联,并使用JPA嵌入式ID @Embedded类...JPA @OneToMany关系作为@Id
我有一个Person
类与它的ID:
@Entity
public class Person{
@EmbeddedId
private PersonCode personCode;
private String name;
@Embeddable
public static class PersonCode{
private String code;
}
}
然后我想创建一个类Company
与联想:
@Entity
public class Company{
private String name;
@OneToMany
private List<PersonCode> employees;
}
但是我有这样的例外:
Caused by: org.hibernate.AnnotationException: Use of @OneToMany or @ManyToMany targeting an unmapped class: example.domain.Company.employees[example.domain.Person$PersonCode]
由于一些DDD reccomendation,我试图弄清楚如何管理两个实体的关系,而不是两者都不对另一个负责......所以如果有可能使用单个ID类来建立关系很容易实现......所以谢谢你! – rascio 2013-05-14 18:35:08