我有一个实体,它扩展了一个名为AbstractAuditingEntity的审计实体类,在其中一个字段中是
@CreatedDate
@Column(name = "created_date", nullable = false)
@JsonIgnore
private ZonedDateTime createdDate
上述字段与名为
"created_date"
且类型为"timestamp without time zone"
的数据库字段有映射关系。但是在保存此实体时,PostgresSQL会抛出以下错误:
Caused by: org.postgresql.util.PSQLException: ERROR: column "created_date" is of type timestamp without time zone but expression is of type bytea
Hint: You will need to rewrite or cast the expression.
我在寻找同样的错误并在这里找到了解决方案:Postgresql UUID supported by Hibernate?
但是该解决方案适用于java.util.UUID
,解决方案建议在具有UUID类型的字段上添加注释@Type(type="pg-uuid")
。
是否存在像pg-uuid
这样的现成类型值,适用于ZonedDateTime
?有关Hibernate @Type
注释的不同值常量的任何参考链接吗?
还是应该编写自定义反序列化器类?如何编写此类反序列化器类,有任何参考链接吗?
PostgresSQL Version : 9.6,
<liquibase-hibernate5.version>3.6</liquibase-hibernate5.version>
org.hibernate.type
的调试日志吗?如果类型已注册,您应该会发现类似于http://pastebin.com/t2xh5UvM的内容,并且应该可以正常工作。 - coladict