MyBatis multiple resultsets

一个人想着一个人 提交于 2019-12-18 07:11:30

问题


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.


回答1:


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>


来源:https://stackoverflow.com/questions/6388605/mybatis-multiple-resultsets

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!