发现配置:
Java代码
- <resultMap type="com.demo.sys.entity.Module" id="moduleMap">
- <id property="id" column="id" />
- <result property="name" column="name" />
- <result property="remark" column="remark" />
- <result property="createDate" column="createdate" />
- <result property="updateDate" column="updateDate" />
- <association property="parent" column="parent_id"
- resultMap="moduleMap" select="queryModule">
- </association>
- <collection property="childs" column="parent_id"
- javaType="ArrayList" ofType="com.demo.sys.entity.Module"
- select="queryChildList">
- </collection>
- </resultMap>
- <select id="queryList" parameterMap="moduleMap" resultMap="moduleMap">
- select * from sys_module where id =#{id}
- </select>
更改配置:
Java代码
- <resultMap type="com.demo.sys.entity.Module" id="moduleMap">
- <id property="id" column="id" />
- <result property="name" column="name" />
- <result property="remark" column="remark" />
- <result property="createDate" column="createdate" />
- <result property="updateDate" column="updateDate" />
- <association property="parent" column="parent_id"
- resultMap="moduleMap" select="queryModule">
- </association>
- <collection property="childs" column="parent_id"
- javaType="ArrayList" ofType="com.demo.sys.entity.Module"
- select="queryChildList">
- </collection>
- </resultMap>
- <select id="queryList" parameterType="com.demo.sys.entity.Module" resultMap="moduleMap">
- select * from sys_module where id =#{id}
- </select>
parameterMap="moduleMap" -------》parameterType="com.demo.sys.entity.Module"
解决了Mybatis中Parameter Maps collection does not contain value for xxx 的问题了。
查看Mybatis官方资料:
SQL映射的XML文件:parameterMap 已经废弃了,现在使用parameterType来处理。
时间: 2024-11-06 13:52:12