【问题标题】:IntelliJ persistence tool type mappingIntelliJ 持久化工具类型映射
【发布时间】:2017-05-07 21:21:42
【问题描述】:

我有一个 PostgreSQL 数据库架构。我正在尝试使用集成的持久性工具从 IntelliJ 中的该模式生成 JPA 实体。一切正常,除了时间戳的映射。

持久性工具正在尝试将 PostgreSQL TIMESTAMP 数据类型映射到 java.lang.Objectjava.io.Serializable。我无法将映射更改为LocalDateTimeString 或其他任何内容。

有没有办法设置正确的映射类型?

更新:

我得到以下异常:

SchemaManagementException: Schema-validation: wrong column type encountered in column [timestamp] in table [ProcessEvent]; found [timestamptz (Types#TIMESTAMP)], but expecting [bytea (Types#VARBINARY)]

【问题讨论】:

    标签: java postgresql intellij-idea persistence


    【解决方案1】:

    您是否为属性使用了正确的注解?

    @Entity
    public class Employee {
        ...
        @Basic
        @Temporal(DATE)
        private Calendar startDate;
        ...
    }
    

    请看:https://en.wikibooks.org/wiki/Java_Persistence/Basic_Attributes#Temporal.2C_Dates.2C_Times.2C_Timestamps_and_Calendars

    【讨论】:

    • 好的,我必须使用 Calendar 或 java.sql.time。
    猜你喜欢
    • 2013-10-18
    • 1970-01-01
    • 2019-12-07
    • 1970-01-01
    • 2018-07-27
    • 2016-05-03
    • 1970-01-01
    • 2018-05-25
    • 2021-10-16
    相关资源
    最近更新 更多