0
我有以下類的結構:Hibernate進行多層次的混合繼承策略層次結構
我想生成與休眠以下三個表:
- PlanItem:所有它的屬性
- 任務:與所有的屬性和它的子屬性
- 階段:其所有在進貢
我試圖混合inheritancetypes,但它沒有工作:
@Entity
@Inheritance(strategy = InheritanceType.JOINED)
public abstract class PlanItem {...}
@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
public class Stage extends PlanItem {...}
@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
public class Task extends PlanItem {...}
@Entity
public class HumanTask extends Task {...}
@Entity
public class ProcessTask extends Task {...}
@Entity
public class CaseTask extends Task {...}
我已經與輔助表試驗,得到了或多或少的期望的結果:
@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
public abstract class PlanItem {...}
@Entity
@SecondaryTable(name = "Stage")
public class Stage extends PlanItem {...}
@Entity
@SecondaryTable(name = "Task")
public class Task extends PlanItem {...}
@Entity
@SecondaryTable(name = "Task")
public class HumanTask extends Task {...}
@Entity
@SecondaryTable(name = "Task")
public class ProcessTask extends Task {...}
@Entity
@SecondaryTable(name = "Task")
public class CaseTask extends Task {...}
但我想知道是否有更優雅和簡單的解決方案?
謝謝你的回答。在你的鏈接中,他們說「這個問題的解決方案已經在5.0的代碼庫中了,我沒有預見到這個問題將在4.x中解決。」我使用了Hibernate-core-5.0.2.final.jar,但這個版本的Hibernate也不可行。 – Tim
這就是爲什麼它沒有解決,仍然沒有完全實施。 –