是的,有可能。您应该只在顶部的抽象类上拥有MappedSuperClass(它本身不会持久化),并在实现类上添加Entity批注。
尝试将其更改为如下所示:
@MappedSuperclasspublic abstract class OpsItem extends Model { @ManyToOne public RetailOpsBranch report;}@Entity@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)public class AItem extends OpsItem {...}@Entity@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)public class BItem extends OpsItem {...}检查hibernate文档的此部分以获取有关其使用的详细信息:http
:
//docs.jboss.org/hibernate/annotations/3.5/reference/en/html_single/#d0e1168
更新
抱歉,完全错过了每班位的餐桌。Hibernate不支持为每个类的表映射抽象对象(如果所有实现都在单个SQL表中,则只能映射List,并且TABLE_PER_CLASS使用“每个具体类的表”策略。
有关限制和策略的详细信息,请参见:http :
//docs.jboss.org/hibernate/orm/4.1/manual/en-US/html_single/#inheritance-
limitations



