【问题标题】:how to add day to date in ejbql如何在 ejbql 中添加日期
【发布时间】:2013-01-30 02:50:39
【问题描述】:

我正在尝试在我的 EJB 查询中实现 dateadd。我尝试了类似的方法,但它不起作用:

select t.date + 1 from Table t

一旦我尝试执行该代码,就会出现此异常:

org.hibernate.exception.SQLGrammarException: ERROR: operator does not exist: timestamp without time zone + integer Hint: No operator matches the given name and argument type(s). You might need to add explicit type casts. Position: 93

我也尝试将 1 转换为日期和间隔,但查询结果只会为空。 我只是想知道,是否真的可以在 EJB 查询中的给定日期中添加天数

【问题讨论】:

    标签: ejb ejb-3.0 dateadd ejbql


    【解决方案1】:

    EJBQL 不支持日期算术,也不可能从日期中提取日期,JPQL 也不支持。

    根据 JPA 提供程序(Hibernate、EclipseLink 等),可能会有有用的供应商特定扩展和调用数据库函数的可能性。比如搭配EclipseLinkFUNC就可以使用了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-02-27
      • 1970-01-01
      • 1970-01-01
      • 2015-12-02
      • 2017-03-10
      • 2021-08-01
      相关资源
      最近更新 更多