转:http://hi.baidu.com/jy4214/blog/item/192ad99004b09992a877a464.html
运行环境
struts2+spring3.0+mybatis
Mapper配置
<select id="getSiteBySiteName" statementType="CALLABLE">
{call Q_SITE_TEST(
#{BelongsToNetwork,jdbcType=VARCHAR,mode=IN},
#{rf,jdbcType=CURSOR,mode=OUT,resultMap=Q_SITE_TEST_MAP,javaType=java.sql.ResultSet})}
</select>
<resultMap type="com.bee.pojo.TestSite" id="Q_SITE_TEST_MAP">
<result column="SITENAME" jdbcType="DECIMAL" property="sitename" />
<result column="SITENO" jdbcType="VARCHAR" property="siteno" />
</resultMap>
action调用
public String getSiteDetail(){
Map<String ,Object> map=new HashMap<String, Object>();
map.put("BelongsToNetwork", "华南中心");
iservice.getSiteBySiteName(map);
List siteList=(List)map.get("rf");
req().setAttribute("siteList", siteList);
System.out.println(siteList.size());
return this.SUCCESS;
}
存储过程
create or replace procedure Q_Site_test(BelongsToNetwork in varchar2,rf out sys_refcursor) is
--根据所属网点查询下级网点资料
--参数说明
--BelongsToNetwork:所属网点
begin
open rf for
select siteno, sitename from tab_sitelist t where belognsite=BelongsToNetwork;
end Q_Site_test;
注意这里好像不能使用parameterMap,以下这种配置方式会报错
<select id="getSiteBySiteName" statementType="CALLABLE" parameterMap="paramMap">
{call Q_SITE_TEST(
#{BelongsToNetwork},
#{rf})}
</select>
<parameterMap type="java.util.HashMap" id="paramMap" >
<parameter property="BelongsToNetwork" javaType="String" jdbcType="VARCHAR"/>
<parameter property="rf" jdbcType="CURSOR" javaType="java.sql.ResultSet" mode="OUT" resultMap="Q_SITE_TEST_MAP" />
</parameterMap>