struts2+spring3+mybatis为框架:
1、自定义函数如下:
create or replace function fn_get_unit_workinfo_list(--返回车辆状态统计信息 p_unitid number, --车台ID p_begin_time varchar2, --查询的开始时间,格式为"yyyy-mm-dd",不需要指定时、分、秒 p_end_time varchar2 --查询的结束时间,格式为"yyyy-mm-dd",不需要指定时、分、秒 )return sys_refcursor as l_retVal sys_refcursor; begin省略后面的内容,该函数返回的为游标。
2、mapper.xml
<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>3、报错为:
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
请大家不吝赐教,先谢谢了。
直接
{callfn_get_unit_workinfo_list(#{unitid,jdbcType=DECIMAL,mode=IN},#{startTime,jdbcType=VARCHAR,mode=IN},#{endTime,jdbcType=VARCHAR,mode=IN})}resultType设置成sys_refcursor 对应的model类
这个问题已解决,将解决的方式贴出来:
<selectid="selectAllCursor"parameterType="Map"statementType="CALLABLE">
<![CDATA[
{#{result,mode=OUT,jdbcType=CURSOR}=callfn_query_history_all(
#{calletter,jdbcType=VARCHAR,mode=IN},
#{startTime,jdbcType=TIMESTAMP,mode=IN},
#{endTime,jdbcType=TIMESTAMP,mode=IN},
#{speed,mode=IN}
)
}
]]>
</select>
执行之后,得到map里面的resutl:
super.getSqlSessionTemplate()
.selectList("selectAllCursor",map);
if(map!=null&&map.containsKey("result")){
OracleResultSetset=(OracleResultSet)map.get("result");
}
d版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。