MyBatis multiple resultsets

James Woods picture James Woods · Jun 17, 2011 · Viewed 9.8k times · Source

I am currently migrating code from iBatis 2 to MyBatis 3. I have a function that returns multiple results sets which we map to different classes. In iBatis we where able to map the different results using a comma separated list int the resultType like so:

<select id="findCashItems" parameterType="map" resultType="AdminCashBalance, AdminCashMovement, AdminCashTrx">
    exec RequestActualAdministrativeData #{portfolioId}
</select>

But this does not appear to work in MyBatis 3. I can't find anything in the documentation except for a configuration item that, by default, enables multiple resultsets. But nothing on how to actually process them.

Answer

James Woods picture James Woods · Jun 20, 2011

Using a resultMap with a comma separated list of result maps fixes this issue.

<resultMap id="adminCashBalance" type="AdminCashBalance">
...
</resultMap>

<resultMap id="adminCashMovement" type="AdminCashMovement">
...
</resultMap>

<resultMap id="adminCashTrx" type="AdminCashTrx">
...
</resultMap>

<select id="findCashItems" parameterType="map" resultMap="adminCashBalance, adminCashMovement, adminCashTrx">
    exec RequestActualAdministrativeData #{portfolioId}
</select>