控制台输出:
Caused by: org.hibernate.MappingException: No discriminator found for Subclass. Discriminator is needed when 'single-table-per-hierarchy' is used and a class has subclasses
at org.hibernate.mapping.SingleTableSubclass.validate(SingleTableSubclass.java:49) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
at org.hibernate.boot.internal.MetadataImpl.validate(MetadataImpl.java:329) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:443) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:879) ~[hibernate-entitymanager-5.0.12.Final.jar:5.0.12.Final]
我收到此错误但我在课堂上绝对有@DiscriminatorValue
。
超类注释:
@Entity
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(
name="entity_type",
discriminatorType=DiscriminatorType.STRING
)
控制台错误中包含的子类的注释:
@Entity
@DiscriminatorValue(value="keyword")
我完全不知道该做什么。
编辑:
以下是完整的课程:
超类
@Entity
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(
name="entity_type",
discriminatorType=DiscriminatorType.STRING
)
public class Superclass implements java.io.Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private Long segmentId;
private String entityType;
private EntityLists positiveEntityList;
private EntityLists queryExpansionEntityList;
private EntityLists negativeEntityList;
private EntityLists queryRestrictionList;
public Superclass() {
}
}
子类
@Entity(name = "Subclass")
@DiscriminatorValue(value = "keyword")
public class Subclass extends Superclass implements java.io.Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private Long segmentId;
private String entityType;
@OneToOne
@JoinColumn(name="postive_entity_list_id")
private KeywordLists positiveEntityList;
@OneToOne
@JoinColumn(name = "query_expansion_list_id")
private KeywordLists queryExpansionEntityList;
@OneToOne
@JoinColumn(name = "negative_entity_list_id")
private KeywordLists negativeEntityList;
@OneToOne
@JoinColumn(name = "query_restriction_list_id")
private KeywordLists queryRestrictionList;
public Subclass() {
}
}
编辑2:
其他可能相关的信息(可能?)