如何使用jooq在H2中编写日期范围查询

时间:2015-01-07 14:01:36

标签: java sql ibatis jooq

我正在使用mybatis库来执行本机sql查询。 我正在使用jooq为不同的方言生成动态sql查询。

语法:

condition = condition.and(DSL.field("START_TIME_").between("2014-10-12")
                                    .and("2014-10-12"));

Error:
org.apache.ibatis.exceptions.PersistenceException: 
### Error querying database.  Cause: org.h2.jdbc.JdbcSQLException: Syntax error in SQL statement "SELECT * FROM ACT_HI_PROCINST WHERE (DELETE_REASON_ IS NULL AND START_TIME_ BETWEEN CAST(:[*]1 AS VARCHAR) AND CAST(:2 AS VARCHAR))
    LIMIT ? OFFSET ? "; expected "NOT, EXISTS, INTERSECTS, SELECT, FROM"; SQL statement:

select * 
from ACT_HI_PROCINST 
where (DELETE_REASON_ is null and START_TIME_ between cast(:1 as varchar) and cast(:2 as varchar))

0 个答案:

没有答案