MyBatis多个结果集 [英] MyBatis multiple resultsets

查看:950
本文介绍了MyBatis多个结果集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在将代码从iBatis 2迁移到MyBatis3.我有一个函数可以返回多个结果集,这些结果集映射到不同的类.在iBatis中,我们可以使用逗号分隔的列表将结果映射到resultType中,如下所示:

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>

但这在MyBatis 3中似乎不起作用.除了默认情况下启用多个结果集的配置项外,我在文档中找不到任何内容.但是没有任何关于如何实际处理它们的信息.

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.

推荐答案

使用带有逗号分隔的结果图列表的resultMap可以解决此问题.

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>

这篇关于MyBatis多个结果集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆