我想创建一个名为
的类型@Entity
class TestType {
@Id
private Long id;
private String field1;
private String field2;
}
@Entity
class Agregator{
@Id
private Long id;
private String name;
@OneToMany
private List<TestType> newTypes;
@OneToMany
private List<TestType> oldTypes;
}
我想拥有3张桌子:
我需要如何定义关系以获得此类表和列?
答案 0 :(得分:1)
@Embeddable
class TestType {
@Id
private Long id;
private String field1;
private String field2;
}
@Entity
class Agregator{
@Id
private Long id;
private String name;
@ElementCollection
private List<TestType> newTypes;
@ElementCollection
private List<TestType> oldTypes;
}