错误绑定OffsetDateTime [操作员不存在:时区<=字符变化的时间戳记]

问题描述 投票:0回答:1

我们正在尝试执行dml,该dml将基于ZonedDateTime删除记录。我们正在使用以下代码,但遇到错误。

dsl.execute ("delete from fieldhistory where createddate <= ? and object = ?", beforeDate.toOffsetDateTime(), objName)

beforeDate是ZonedDateTime,objectName是字符串的情况>

我们正在从postgres获取以下错误。

org.jooq.exception.DataAccessException: SQL [delete from fieldhistory where createddate <= ? and object = ?]; ERROR: operator does not exist: timestamp with time zone <= character varying
  Hint: No operator matches the given name and argument types. You might need to add explicit type casts.
  Position: 56
    at org.jooq_3.13.1.POSTGRES.debug(Unknown Source)
    at org.jooq.impl.Tools.translate(Tools.java:2751)
    at org.jooq.impl.DefaultExecuteContext.sqlException(DefaultExecuteContext.java:755)
    at org.jooq.impl.AbstractQuery.execute(AbstractQuery.java:385)
    at org.jooq.impl.DefaultDSLContext.execute(DefaultDSLContext.java:1144)

问题是,我们如何在Jooq中绑定日期时间值?

我们正在尝试执行dml,该dml将基于ZonedDateTime删除记录。我们正在使用以下代码,但遇到错误。 dsl.execute(“从fieldhistory中删除,其中createddate <=?和...

jooq sqlbindparameter
1个回答
1
投票

出于历史原因,jOOQ将所有JSR-310时间绑定为字符串,而不是相关对象类型。这是因为直到最近,JDBC驱动程序还不原生支持JSR-310类型,因此,使用字符串并不是一个不好的默认设置。

© www.soinside.com 2019 - 2024. All rights reserved.