我的類結構看起來像這樣...我有兩個單獨的策略在這裏實現,但是繼承策略的根類,即InheritanceType.JOINED被用於整個層次結構...混合jpa繼承策略 - inheritanceType.JOINED with inheritanceType.SINGLE_TABLE
@Entity
@Inheritance(strategy = InheritanceType.JOINED)
@DiscriminatorColumn(name = "typeName", discriminatorType = DiscriminatorType.STRING, length = 100)
@Table(name="table_A")
public abstract class A{
...
}
@Entity
@Table(name = "table_B")
@PrimaryKeyJoinColumn(name = "ID_B")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorValue("SVC")
public abstract class B extends A {
...
}
@Entity
@DiscriminatorValue("C")
public class C extends B {
...
}
@Entity
@DiscriminatorValue("D")
public class D extends B {
...
}
時,我創建「d」的實例,並試圖堅持它,Hibernate是尋找一個名爲「d」表...
我發現一對夫婦的人問同樣的問題...但答案並沒有幫助我...
mixing joined and single table inheritance and querying for all objects - 同樣的問題..
How to mix inheritance strategies with JPA annotations and Hibernate? - 混合single_table與joined ..這對我的情況沒有幫助..
我發現一個[解決方案](http://stackoverflow.com/questions/40679517/how-to-mix-inheritance-type-in- jpa)只使用沒有Hibernate的JPA openJPA。 – 2016-11-24 08:50:17