JPA OneToMany 集合的条件
如果我有这个实体:
@Entity
class Pet {
@Id
long id;
public enum State { ALIVE, DEAD }
@Enumerated(EnumType.STRING)
@...
State state;
@...
String name;
}
我可以创建如下映射吗:
@Entity
class Owner {
@OneToMany(condition="state = ALIVE") // or something like that
Set<Pet> alivePets;
@OneToMany(condition="state = DEAD")
Set<Pet> deadPets;
}