1
假設我有:用JPA映射多態列表?
//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知道把狗和貓在其相應的表(或任何繼承映射策略是用過的)。它也知道如何在查詢時收回它?
即使文檔鏈接可能是問題的有用的解決方案將被大概理解以及。 – 2017-08-16 19:48:54