【问题标题】:Spring JPA with criteria builder convert timestamp with timezone to local time with given time zone带有标准构建器的 Spring JPA 将带有时区的时间戳转换为带有给定时区的本地时间
【发布时间】:2020-02-22 02:24:43
【问题描述】:

我使用 PostgreSQL 作为数据库,我有一个 timestamptz 列 我想把它转换成给定的时区。

select 
  shipment0_.estimated_delivery_date_time at time zone 'IST'
from 
  shipment shipment0_

是查询, 如何使用带有时区的 JPA 标准作为用户输入来实现它。 我不能使用本机查询或 JPQL,因为我已经有其他使用条件 API 的过滤器

【问题讨论】:

    标签: postgresql hibernate spring-data-jpa hibernate-criteria


    【解决方案1】:

    根据这篇博文https://vladmihalcea.com/sql-functions-multiple-parameters-jpql-hibernate/

    管理使用 MetadataBuilderContributor 注册自定义函数

    【讨论】:

      猜你喜欢
      • 2018-12-18
      • 1970-01-01
      • 2021-09-22
      • 1970-01-01
      • 1970-01-01
      • 2020-11-27
      • 2020-12-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多