我有以下类结构:
我想用hibernate生成以下三个表:
我试图混合继承类型,但它没有工作:
@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 {...}
但我想知道是否存在更优雅和简单的解决方案?