不想战斗 2022-03-22 12:33 采纳率: 33.3%
浏览 201

mybaits collection 父查询参数如何传进子查询中

##父集合 id在resultMap中,name在父查询的parameterType中
<resultMap type="cn.xxxVO" id="fatherResult">
        <result property="id"    column="id"    />
        <collection property="xxxList" ofType="cn.xxxResVO" javaType="java.util.List" column="{id, name}" select="selectResResult" />
    </resultMap>

##父查询
<select id="selectFatherResResult" resultMap="fatherResult" parameterType="cn.xxxDTO">
        select id from AAA 
</select>

##子查询
 <select id="selectSonResResult" resultMap="sonResResult" parameterType="java.util.Map">
        select a,b,c from xxx 
        <where>
            <if test="id!= null and id!= ''">
                and xxx.id = #{id}
            </if>
            <if test="name!= null and name!= ''">
                and xxx.name like concat('%', #{name}, '%')
            </if>
        </where>
    </select>

##查询报错
nested exception is org.apache.ibatis.executor.result.ResultMapException: Error attempting to get column 'name' from result set. Cause: org.apache.ibatis.executor.result.ResultMapException: Error attempting to get column 'name' from result set. Cause: java.sql.SQLException: Column 'name' not found.
  • 写回答

2条回答 默认 最新

报告相同问题?

问题事件

  • 创建了问题 3月22日

悬赏问题

  • ¥15 Could not load dynamic library 'libcusolver.so.10'
  • ¥15 G0系列单片机HAL库中景园gc9307液晶驱动芯片无法使用硬件SPI+DMA驱动,如何解决?
  • ¥15 nasm x86 变量归零
  • ¥65 Tree 树形控件实现单选功能,可以使用element也可以手写一个,实现全选为全选状态
  • ¥60 寻抓云闪付tn组成网页付款链接
  • ¥16 寻字节跳动内部人员帮推简历
  • ¥20 如何通过sentry收集上传Android ndk的崩溃?
  • ¥30 有关数值生成的稳健性探讨
  • ¥20 关于C/C++图形界面设计问题
  • ¥15 QT+Gstreamer框架开发视频采集,无法将waylandsink视频绑定qt窗口