Hibernate 架构验证:缺少具有jpa多级继承的表
我需要使用JPA进行3级继承,但每个只需要一个datatable Cell_ 这里是我的实体Hibernate 架构验证:缺少具有jpa多级继承的表,hibernate,jpa,multiple-inheritance,Hibernate,Jpa,Multiple Inheritance,我需要使用JPA进行3级继承,但每个只需要一个datatable Cell_ 这里是我的实体 @MappedSuperclass @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) public class PersistEntity implements Serializable { private static final long serialVersionUID = 1L; @Id @Colu
@MappedSuperclass
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public class PersistEntity implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Column(name = "ID", nullable = false)
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
...
}
第二级
@MappedSuperclass
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public class PersistEntityPer extends PersistEntity {
private static final long serialVersionUID = 1L;
@Temporal(TemporalType.DATE)
@Column(
name = "PERIOD_START",
nullable = false)
private Date periodStart;
@Temporal(TemporalType.DATE)
@Column(
name = "PERIOD_END",
nullable = false)
private Date periodEnd;
}
最后一级呢
@Entity
@Table(name = "dbo.CELLAR_PER")
public class CellarPer extends PersistEntityPer {
private static final long serialVersionUID = 1L;
@ManyToOne
@JoinColumn(
name = "CELLAR_CASE_ID",
nullable = false)
private CellarCase cellarCase;
}
我的问题是,在运行tomcat服务器时出现以下错误:
Caused by: org.hibernate.tool.schema.spi.SchemaManagementException: Schema-validation: missing table [dbo.CELLAR_PER]
at org.hibernate.tool.schema.internal.AbstractSchemaValidator.validateTable(AbstractSchemaValidator.java:121)
at org.hibernate.tool.schema.internal.GroupedSchemaValidatorImpl.validateTables(GroupedSchemaValidatorImpl.java:42)
at org.hibernate.tool.schema.internal.AbstractSchemaValidator.performValidation(AbstractSchemaValidator.java:89)
at org.hibernate.tool.schema.internal.AbstractSchemaValidator.doValidation(AbstractSchemaValidator.java:68)
at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:191)
at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process(SchemaManagementToolCoordinator.java:72)
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:309)
at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:452)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:889)
... 48 common frames omitted
拜托,你能帮我修复这个错误吗?好的,我只是因为dbo而浪费了时间。那只是。。。谢谢你的帮助你说得对。以下是解决方案: 在我的实体声明中,我有:
@Table(name = "dbo.CELLAR_PER")
我刚刚移除了dbo。从宣言中删除。解决办法是:
@Table(name = "CELLAR_PER")
SINGLE_TABLE的思想是,根类定义表,子类被持久化到表中,并且您只在根类中定义继承。您似乎想在子类中定义表,但这是行不通的。为什么不看看您的JPA提供商创建了哪些表?aka debuggingJPA创建了下表,该表对应于我想要的=>代码创建表dbo.ceral\u PER ID int identity not null,VERSION int not null,PERIOD\u START date not null,PERIOD\u END date not null,ceral\u CASE\u ID int not null,primary key ID;代码dbo是模式名还是表名?回答您自己的问题是可以的,但是如果您提供了一个答案,请提供一个实际的答案来解释问题是什么以及如何解决问题。你发布的是一条评论。