网上mybatis读取游标的方法大致都是这样:
<select id="selectCarWorkInfo" parameterType="Map" statementType="CALLABLE">
#{result,jdbcType=CURSOR,mode=OUT,javaType=java.sql.ResultSet}
={call fn_get_unit_workinfo_list(
#{unitid,jdbcType=DECIMAL,mode=IN},
#{startTime,jdbcType=VARCHAR,mode=IN},
#{endTime,jdbcType=VARCHAR,mode=IN}
)
}
</select>
但是我写入statementType="CALLABLE"后总是报错:
2013-07-24 14:13:13,211 [main] DEBUG [java.sql.Connection] - ooo Connection Opened
2013-07-24 14:13:13,277 [main] ERROR [org.liteframework.core.dao.impl.GenericDaoMyBatis] - nested exception is org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause: java.lang.ClassCastException: org.apache.ibatis.executor.statement.CallableStatementHandler cannot be cast to org.apache.ibatis.executor.statement.PreparedStatementHandler
### The error may exist in file [D:\eclipseWorkspace\driverBookTrade\build\classes\com\chinaGPS\driverBookTrade\model\mapper\CarWorkInfoMapper.xml]
### The error may involve com.chinaGPS.driverBookTrade.model.pojo.CarWorkInfo.selectCarWorkInfo
### The error occurred while executing a query
### Cause: java.lang.ClassCastException: org.apache.ibatis.executor.statement.CallableStatementHandler cannot be cast to org.apache.ibatis.executor.statement.PreparedStatementHandler; nested exception is org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause: java.lang.ClassCastException: org.apache.ibatis.executor.statement.CallableStatementHandler cannot be cast to org.apache.ibatis.executor.statement.PreparedStatementHandler
### The error may exist in file [D:\eclipseWorkspace\driverBookTrade\build\classes\com\chinaGPS\driverBookTrade\model\mapper\CarWorkInfoMapper.xml]
### The error may involve com.chinaGPS.driverBookTrade.model.pojo.CarWorkInfo.selectCarWorkInfo
### The error occurred while executing a query
### Cause: java.lang.ClassCastException: org.apache.ibatis.executor.statement.CallableStatementHandler cannot be cast to org.apache.ibatis.executor.statement.PreparedStatementHandler
若去掉该属性,可以执行成功,但是不能读到值。先记录几个相关的链接地址:
http://www.360doc.com/content/12/1019/12/7471983_242394924.shtml(边缘问题)
bbs.youkuaiyun.com/topics/370015077?page=1(差不多的问题)
http://sishuok.com/forum/blogPost/list/3898.html(实例)
http://bbs.youkuaiyun.com/topics/390345860(貌似已解决,但不能解决我的问题)
总结一下:感觉与本人项目封装的框架相关,项目进度优先,先将该问题遗留,待解决。
本文详细探讨了使用MyBatis时遇到的CallableStatementHandler报错问题,包括错误信息解读、可能原因分析及解决方案。通过实例演示,帮助开发者理解并解决在项目中遇到的类似问题。

459

被折叠的 条评论
为什么被折叠?



