【发布时间】:2013-03-11 05:00:22
【问题描述】:
假设我有:
//inheritance annotations
public abstract class Animal {
private int noOfLegs;
//...
}
//inheritance annotations
public class Cat extends Animal {
//cat stuff
}
//inheritance annotations
public class Dog extends Animal {
//dog stuff
}
@Entity
public class House {
@OneToMany
@JoinTable(//join stuff
private List<Animal> animals;
//hose stuff
}
现在,如果我将猫和狗都放入我的房子,并坚持我的房子,JPA 是否知道将狗和猫放入相应的表中(或使用任何继承映射策略)。也知道查询的时候怎么取回来吗?
【问题讨论】:
标签: java hibernate inheritance jpa orm