模式验证:缺少具有jpa多级继承的表[关闭]

问题描述 投票:0回答:2

我需要有JPA的3级继承(但只有一个数据表CELLAR_PER)这是我的实体

@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

拜托,你能帮我修一下这个错误吗?

hibernate jpa multiple-inheritance
2个回答
0
投票

你是对的。这是解决方案:

在我的实体声明中,我有这个:

@Table(name = "dbo.CELLAR_PER")

我刚从声明中删除了dbo.。解决方案是:

@Table(name = "CELLAR_PER")

-1
投票

是的,我因为“dbo”而浪费时间。那只是...感谢您的帮助

© www.soinside.com 2019 - 2024. All rights reserved.