【问题标题】:Hibernate Schema Validation Error when mapping LocalDateTime to TIMESTAMP将 LocalDateTime 映射到 TIMESTAMP 时出现休眠模式验证错误
【发布时间】:2018-09-30 03:25:55
【问题描述】:

我在其中一个实体中添加了一个 LocalDateTime 列,并且根据 Postgresql documentation,这会以 SQL 方式映射到 TIMESTAMP 类型。

但是,当在validate 模式下使用 Hibernate 运行 Spring Boot 应用程序时,由于以下原因启动失败:

Caused by: org.hibernate.tool.schema.spi.SchemaManagementException: Schema-validation: wrong column type encountered in column [request_date_time] in table [prepayment]; found [timestamp (Types#TIMESTAMP)], but expecting [bytea (Types#VARBINARY)]

有什么想法会导致这种行为吗?

【问题讨论】:

    标签: postgresql hibernate spring-boot spring-data


    【解决方案1】:

    此问题可能是由于使用不支持 LocalDateTime、ZonedDateTime 和类似日期类等类型的 hibernate 版本引起的。 为了解决这个问题,请尝试添加 hibernate-java8 依赖,例如,如果您使用的是 gradle:

    编译组:'org.hibernate',名称:'hibernate-java8',版本: '5.0.12.Final'

    【讨论】:

    • 谢谢,解决了。不了解这个“hibernate-java8”项目,很高兴知道。
    猜你喜欢
    • 2017-03-23
    • 1970-01-01
    • 2015-07-19
    • 2018-05-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-27
    • 1970-01-01
    相关资源
    最近更新 更多