postgresql - 在 hibernate 中获取具有时区值的 itimestamp

标签 postgresql hibernate spring-boot

我正在使用 Hibernate,Spring Boot 和 Postgres。我有一个 time with time zone 列 和另一个 date 列。我尝试添加这两列以获取 timestamp with timezone value。但是使用 hibernate 查询只返回 timestamp without time zone。有什么办法可以达到同样的效果

我的查询是这样的

@Query(value = "select date_col + time_with_timestamp_column from myTable", nativeQuery = true) 时间戳 fetchvalue();

最佳答案

如果您使用的是 Spring Data,则可以通过 @Query(..., native=true) 使查询成为原生查询。这应该会导致查询作为实际 SQL 而不是 JPQL 执行,这可能会解决类型问题

关于postgresql - 在 hibernate 中获取具有时区值的 itimestamp,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51656525/

相关文章:

python - psycopg2:使用外键插入时出错

spring-boot - @AutoConfigureAfter 未按预期工作

java - Flyway和 hibernate : Cannot populate data to initial database

java - 如何使用 JPA 和 Join 优化请求?

sql - 如何使用 Go 函数更新 PostgresQL 表中的多个列

postgresql - 在 Postgresql 中相同的查询给出 true 和 false 的相同词

存储在表中的类型的 Postgresql 返回变量

hibernate - 生成的完整构造函数包含太多参数

hibernate - Grails 有很多 : find all master records with a child that matches a criteria

java - 我应该在 JPA 实体 equals 方法中使用 getter 或字段吗?