【发布时间】:2014-04-13 20:51:24
【问题描述】:
我们一直在调试通过 Hibernate 从运行 Java 的应用服务器执行的 SQL 查询的问题。错误:
[3/10/14 10:52:07:143 EDT] 0000a984 JDBCException W org.hibernate.util.JDBCExceptionReporter logExceptions SQL Error: 1878, SQLState: 22008
[3/10/14 10:52:07:144 EDT] 0000a984 JDBCException E org.hibernate.util.JDBCExceptionReporter logExceptions ORA-01878: specified field not found in datetime or interval
我们已经能够将范围缩小到下面的简单 SQL。
select *
from MY_TABLE T
where T.MY_TIMESTAMP >= (CURRENT_TIMESTAMP - interval '1' hour );
当我们在同一个数据库中运行它时,我们得到了错误:
ORA-01878: specified field not found in datetime or interval
01878. 00000 - "specified field not found in datetime or interval"
*Cause: The specified field was not found in the datetime or interval.
*Action: Make sure that the specified field is in the datetime or interval.
MY_TIMESTAMP 列定义为TIMESTAMP(6)。
FWIW,如果我们将上面 SQL 中的比较从 >= 更改为 <=,则查询有效。
我们假设这与时间变化有关(我们在美国/纽约),但我们在调试时遇到了问题。
此外,我们在通过 MyBatis 运行的类似查询中看到了这个问题,错误看起来像:
### Error querying database. Cause: java.sql.SQLException: ORA-01878: specified field not found in datetime or interval
### The error may involve defaultParameterMap
### The error occurred while setting parameters
### Cause: java.sql.SQLException: ORA-01878: specified field not found in datetime or interval
更新:Windows 上的一位队友通过取消选中“自动调整夏令时时钟”更改了她的 Windows 日期和时间设置,然后打开了一个新的 SQLDeveloper 实例。第二个实例能够毫无问题地运行查询,但第一个实例(使用旧的 DST 设置)仍然失败。
【问题讨论】:
标签: oracle timezone timestamp dst