zoukankan      html  css  js  c++  java
  • mybatis中调用游标,存储过程,函数

        在ibatis和Mybatis对存储过程和函数函数的调用的配置Xml是不一样的,以下是针对Mybatis 3.2的环境进行操作的。

    •    第一步配置Mapper的xml内容
    <mapper namespace="com.rrtong.rrt.auto.dao.SelfStatisticDataDao">
     	<resultMap id="SelfStatisticData" type="SelfStatisticData">  
            <id 	column="name" 	property="name" />  
            <result column="count" 	property="count"/>        
        </resultMap>
    	
    	<select id="getSelfStatisticData" parameterType="HashMap" statementType="CALLABLE" >
     	    {#{result,mode=OUT,jdbcType=CURSOR, resultMap=SelfStatisticData} = call PKG_RRT_SelfStatics.Fn_GetSelfStatData(#{userCode,jdbcType=VARCHAR,mode=IN})	}    	
    	</select> 	
    </mapper>

                   说明:

                               1、result对应的是oracle自定义函数返回的游标

                               2、映射对象resultMap对应的是SelfStaticData

                               3、userCode为传入参数

    • 在Service层中如何得到该游标的数据集呢?下面为调用实例,
    @Service
    public class SelfStatisticDataServiceImpl implements SelfStatisticDataService{
    	@Resource
    	SelfStatisticDataCache selfStatisticDataCache;
    	
    	public List<?> getSelfStatisticData(String userCode){		
    		List<?> selfStaticDataList = new ArrayList<Map<String,Object>>();
    		HashMap<String,Object> statMap = new HashMap<String,Object>();
    		statMap.put("userCode", userCode);
                    /*设定游标结果写入的变量*/
                    statMap.put("result", selfStaticDataList);	
    		
    		selfStatisticDataCache.getSelfStatisticData(statMap);
    		/*获取返回的游标结果集*/
                    selfStaticDataList = (List<?>) statMap.get("result");	
    
    		return selfStaticDataList;
    	}
    }
    

     转载:https://www.cnblogs.com/wala-wo/p/5119236.html

    转载:https://www.cnblogs.com/xushirong/p/6999568.html   存储过程,和函数

  • 相关阅读:
    使用binlog日志还原数据详解
    js自定义双击函数
    部署全局ajax处理
    mysql开启binlog日志和慢查询日志
    iOS-静态库,动态库,framework浅析(三)
    iOS-静态库,动态库,framework浅析(二)
    ios-静态库,动态库,framework浅析(一)
    iOS
    xcode工程编译错误:The maximum number of apps for free development profiles has been reached.
    iOS
  • 原文地址:https://www.cnblogs.com/ConfidentLiu/p/10568438.html
Copyright © 2011-2022 走看看