我有一个实体,在其中嵌入了另一个嵌入了embeddeid的实体。当我使用第一个实体时,我得到了这个例外:
it.test.tesctclassPK must not have @Id properties when used as an @EmbeddedId: it.test.firstClass.test.id
但是在密钥类中没有@id注释,甚至在嵌入式类中也没有。
Firstclass是非嵌入类,test是可嵌入类,testpk是嵌入类的嵌入式。
的Firstclass
@Entity
@Table(name = "sometable", schema = "someschema")
public class FirstClass implements Serializable {
private static final long serialVersionUID = 1L;
private FirstClassPK id;
@Embedded
private Test test;
public FirstClass() {
}
/*various attribute getters and setters*/
}
测试
@Entity
@Table(name="sometable", schema="somechema")
@Embeddable
public class Test implements Serializable {
private static final long serialVersionUID = 1L;
private TestPK id;
public Test() {
}
@EmbeddedId
public TestPK getId() {
return this.id;
}
/*various attribute, getters and setters*/
}
TestPk
Test
@Entity
@Table(name="sometable", schema="somechema")
@Embeddable
public class TestPk implements Serializable {
private static final long serialVersionUID = 1L;
public TestPk() {
}
/*various attribute, getters and setters*/
}