ibatis参数设置的问题,困扰了很长时间了
主要问题是,查询的参数赋值总是出现问题,我怀疑是日期类型数据的错误,可是我在描述文件中无论指定什么样的类型似乎都有问题(Date,DateTime,Timestamp),如果不指定类型也不行。请大家看看这个到底怎么回事?
类代码
public int getCountLessThanID(BigDecimal id,Date data)
{
HashMap temp = new HashMap();
temp.put("id", id);
temp.put("modifydate", data);
Object obj = getSqlMapClientTemplate().queryForObject(
"PLAN_FAMILY.getRecordsCountLesThanID", temp);
if (obj != null)
return (Integer) obj;
return 0;
}
ibatis描述文件:
<select id="getRecordsCountLesThanID" resultClass="java.lang.Integer" >
<![CDATA[
select count(t.ID) from PLAN_FAMILY t where t.ID <=#id:Decimal# and t.MODIFYDATE>=#modifydate:Date#
or exists (select p.ID from POP_POPULATE p where p.MODIFYDATE >=#modifydate:Date# and p.ID = t.POPID)
]]>
</select>
错误信息:
Exception in thread "timer" org.springframework.jdbc.UncategorizedSQLException: SqlMapClient operation; uncategorized SQLException for SQL []; SQL state [72000]; error code [1013];
--- The error occurred in com/co/cpis/sqlmap/PLAN_FAMILY_SqlMap.xml.
--- The error occurred while applying a parameter map.
--- Check the PLAN_FAMILY.getRecordsCountLesThanID-InlineParameterMap.
--- Check the statement (query failed).
--- Cause: java.sql.SQLException: ORA-01013: 用户请求取消当前的操作
; nested exception is com.ibatis.common.jdbc.exception.NestedSQLException:
--- The error occurred in com/co/cpis/sqlmap/PLAN_FAMILY_SqlMap.xml.
--- The error occurred while applying a parameter map.
--- Check the PLAN_FAMILY.getRecordsCountLesThanID-InlineParameterMap.
--- Check the statement (query failed).
--- Cause: java.sql.SQLException: ORA-01013: 用户请求取消当前的操作
Caused by: com.ibatis.common.jdbc.exception.NestedSQLException:
--- The error occurred in com/co/cpis/sqlmap/PLAN_FAMILY_SqlMap.xml.
--- The error occurred while applying a parameter map.
--- Check the PLAN_FAMILY.getRecordsCountLesThanID-InlineParameterMap.
--- Check the statement (query failed).
--- Cause: java.sql.SQLException: ORA-01013: 用户请求取消当前的操作
at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryWithCallback(GeneralStatement.java:185)
at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryForObject(GeneralStatement.java:104)
at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapExecutorDelegate.java:566)
at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapExecutorDelegate.java:541)
at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForObject(SqlMapSessionImpl.java:106)
at org.springframework.orm.ibatis.SqlMapClientTemplate$1.doInSqlMapClient(SqlMapClientTemplate.java:243)
at org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClientTemplate.java:193)
at org.springframework.orm.ibatis.SqlMapClientTemplate.queryForObject(SqlMapClientTemplate.java:241)
at com.co.cpis.dao.PlanFamilyDAOImpl.getCountLessThanID(PlanFamilyDAOImpl.java:308)
at com.co.cpis.scheduling.DataSynchronizer.loadPlanFamily2Target(DataSynchronizer.java:2055)
at com.co.cpis.scheduling.DataSynchronizer.execute(DataSynchronizer.java:77)
at com.co.cpis.scheduling.SynchronizationTimerTask.run(SynchronizationTimerTask.java:33)
at java.util.TimerThread.mainLoop(Unknown Source)
at java.util.TimerThread.run(Unknown Source)
Caused by: java.sql.SQLException: ORA-01013: 用户请求取消当前的操作
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:743)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:213)
at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:952)
at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1054)
at oracle.jdbc.driver.T4CPreparedStatement.executeMaybeDescribe(T4CPreparedStatement.java:836)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1116)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3285)
at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:3390)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.execute(NewProxyPreparedStatement.java:989)
at com.ibatis.sqlmap.engine.execution.SqlExecutor.executeQuery(SqlExecutor.java:186)
at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.sqlExecuteQuery(GeneralStatement.java:205)
at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryWithCallback(GeneralStatement.java:173)
... 13 more