스토어드프로시저에 결과셋이 2개이상일때....

예를들어 sp실행시 첫번째 결과셋은 count정보, 두번째 결과셋은 리스트를 보여줄때....

MyBatis Mapper.xml은 다음과 같이 작성하여, resultMap으로 정의한다.


<?xml version="1.0" encoding= "UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
 
<mapper namespace= "TestMapper" >

	<!-- Data집합이 1개면 resultType="hashmap" 가능하나, 2개 이상일때는 resultMap을 사용한다. -->
    <select id ="USP_Test_S001" parameterType="java.util.Map" resultMap="result1,result2" statementType="CALLABLE">
		{ call TestDB.dbo.USP_Test_S001(
			#{Provider_Nm	, mode=IN,	jdbcType=VARCHAR,	javaType=string	},
			#{Site_Nm		, mode=IN,	jdbcType=VARCHAR,	javaType=string	},
			#{Svc_Nm		, mode=IN,	jdbcType=VARCHAR,	javaType=string	},
			#{Flag_Cd		, mode=IN,	jdbcType=VARCHAR,	javaType=string	},
			#{PageSize		, mode=IN,	jdbcType=INTEGER,	javaType=Integer},
			#{PageNum		, mode=IN,	jdbcType=INTEGER,	javaType=Integer},
			#{StartTm		, mode=IN,	jdbcType=VARCHAR,	javaType=string	},
			#{EndTm			, mode=IN,	jdbcType=VARCHAR,	javaType=string	},
			
			#{ErrNum		, mode=OUT,	jdbcType=INTEGER,	javaType=Integer},
			#{ErrSev		, mode=OUT, jdbcType=INTEGER,	javaType=Integer},
			#{ErrState		, mode=OUT, jdbcType=INTEGER,	javaType=Integer},
			#{ErrProc		, mode=OUT, jdbcType=VARCHAR,	javaType=string	},
			#{ErrLine		, mode=OUT, jdbcType=INTEGER,	javaType=Integer},
			#{ErrMsg		, mode=OUT, jdbcType=VARCHAR,	javaType=string	}
		  )
		}
    </select> 
    
	<resultMap id="result1" type="Integer"></resultMap>	
	<resultMap id="result2" type="com.test.vo.TestVO">	
		<result property="providerNm" 	column="Provider_Nm" />
		<result property="siteNm"		column="Site_Nm" />
		<result property="svcNm"		column="Svc_Nm" />
		<result property="itemNo"		column="Item_No" />
		<result property="flagCd" 		column="Flag_Cd" />
		<result property="regDate" 		column="Reg_Date" />
		<result property="modDate" 		column="Mod_Date" />
		<result property="createDate"	column="Create_Date" />
	</resultMap>
</mapper>