【问题标题】:Schema-validation: missing column [event_id] in table [process_event]. Not sure why架构验证:表 [process_event] 中缺少列 [event_id]。不知道为什么
【发布时间】:2022-01-02 05:34:37
【问题描述】:

在我的 springboot 应用程序中,我有以下模型

@Table(name = "process_event", indexes = [
    Index(name = "pe_eventId_idx", columnList = "eventId")
])
@Entity
internal class ProcessEvent {
    @EmbeddedId
    var id: ProcessEventId? = null
}

@Embeddable
internal class ProcessEventId : Serializable {
    @Column(name = "processId", nullable = false, length = 100)
    var processId: String? = null

    @Column(name = "eventId", nullable = false, length = 100)
    var eventId: String? = null

    override fun hashCode(): Int = Objects.hash(processId, eventId)
    override fun equals(other: Any?): Boolean {
        if (this === other) return true
        if (other == null || Hibernate.getClass(this) != Hibernate.getClass(other)) return false

        other as ProcessEventId

        return processId == other.processId &&
                eventId == other.eventId
    }

    companion object {
        private const val serialVersionUID = 2616696968741078700L
    }
}

运行应用程序,出现以下错误Failed to initialize JPA EntityManagerFactory: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.tool.schema.spi.SchemaManagementException: Schema-validation: missing column [event_id] in table [process_event]

模型是使用 intellij 生成的。不知道为什么我会收到此错误。有什么帮助吗?

【问题讨论】:

    标签: hibernate kotlin spring-data-jpa


    【解决方案1】:

    好的,通过添加命名策略解决了这个问题

    jpa:
        hibernate:
          ddl-auto: validate
          naming.physical-strategy: org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
    
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-09-04
      • 2022-11-23
      • 1970-01-01
      • 2020-05-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多