【发布时间】:2019-04-02 03:01:09
【问题描述】:
我在实体中有字段:
@Column(name = "BILL_DATE")
private LocalDate billDate;
我的系统可以使用oracle 和posthresql。在 posgresql 中,此列的类型为 timestamp,但在 oracle 中为 date。当我尝试使用postgeSQL 启动服务器时出现错误:
wrong column type encountered in column [bill_date] in table [charges]; found [timestamp (Types#TIMESTAMP)], but expecting [date (Types#DATE)]
如果我添加注释 @Temporal(TemporalType.DATE) 我会得到另一个错误:
Caused by: org.hibernate.AnnotationException: @Temporal should only be set on a java.util.Date or java.util.Calendar property
但我不想使用java.util.Date 和java.util.Calendar。 如何解决这个问题?
【问题讨论】:
-
哪个休眠版本?
-
@Jerry06
[org.hibernate.Version] [] HHH000412: Hibernate Core {5.2.17.Final} -
应该可以,可能是你的休眠配置有问题
-
龙呢?它将包装 Date 和 TimeStamp 类型,但您将获得格式为 epoch 时间戳:1540802067000
标签: java hibernate timestamp localdate