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
类代码
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
...全文
相关推荐
通过ibatis解决sql注入问题
主要介绍了通过ibatis解决sql注入问题,需要的朋友可以参考下
ibatis乱码解决方法(ibatis独立)
ibatis 乱码解决 ibatis乱码 gbk iso_8859_1 乱码
myBatis和ibatis的区别
自己总结的myBatis和ibatis的区别
C# IBatis IBatis基础 完整项目
这个是初学 I batis学习的 , 我在网上找了很长时间都没有看到有 关于C#的Ibatis的例子,所以我上次了一个自己做的例子 供鸟儿们学习用。 全是自己写的,并且 很详
解决IBatis缓存动态字段问题
如何解决动态数据表名,动态字段名情况下,由ibatis缓存select字段而引起的字段找不到的情况?以下是最简单的解决办法! 本文中内容真实可靠,保证用户很快掌握


