Reputation: 1081
I want to create type called
@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;
}
and I want to have 3 tables:
How I need to define relation to get such tables and columns ?
Upvotes: 0
Views: 40
Reputation: 3423
@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;
}
Upvotes: 1