【发布时间】:2019-01-10 09:31:25
【问题描述】:
我正在使用 Hibernate、Spring Boot 和 Postgres。我有一个time with time zone column 和另一个date 专栏。我尝试添加这两列以获得timestamp with timezone value。但是使用休眠查询只返回timestamp without time zone。有没有办法达到同样的效果
我的查询是这样的
@Query(value = "select date_col + time_with_timestamp_column from myTable" , nativeQuery = true)
Timestamp fetchvalue();
【问题讨论】:
-
使用 psql 中的本机查询对此进行了测试,它正确返回了
timestamp with time zone(或timestamptz短内部名称)。但是,如果该查询被解释为 JPQL,那么可能会添加一些对timestamp的类型转换。尝试在 PG 服务器上启用登录以检查 stackoverflow.com/questions/722221/…。之后不要忘记禁用它,因为这些日志会变得非常庞大。
标签: postgresql hibernate spring-boot