作者:嘻嘻哈哈的二狗子 | 来源:互联网 | 2022-12-09 18:48
如何解决《使用Spring数据的postgres中的时间戳错误:列$COLUMN_NAME的类型为timestamp,没有时区,但表达式的类型为bytea》经验,请问有没有懂的朋友?
使用以下内容:
Oracle JDK 1.8.0._171
Spring Boot 1.5.9-发布
PostgreSQL 9.6
Postgres驱动程序:42.2.4
从以下定义获取错误:
表格栏:
sql
meal_time TIMESTAMP DEFAULT now() NOT NULL
实体属性定义:
java
@Column(name = "meal_time", nullable=false)
private Instant mealTime = Instant.now();
每当我尝试刷新或查询实体时,都会引发错误:
Caused by: org.postgresql.util.PSQLException: ERROR: column "meal_time" is of type timestamp without time zone but expression is of type bytea
Hint: You will need to rewrite or cast the expression.
我可以为这个领域编写一个转换器,但是应该有一种标准的方法,感觉就像是我在寻找一些实例的过程中缺少了一些东西,这些实例我发现非常接近的实现确实有效。