XML文件
<resultMap type="com.wpg.web.dto.TemplateColumnsVO" id="TemplateColumnsVO">
<result column="type" property="type" />
<result column="column_code" property="columnCode" />
<result column="label" property="label" />
<result column="placeholder" property="placeholder" />
<result column="b_required" property="require"/>
<result column="value" property="value"/>
<collection property="values" javaType="ArrayList" ofType="com.wpg.web.dto.ColumnValuesVO">
<result column="dicValue" property="value"/>
<result column="dicName" property="name"/>
<collection property="haha" resultMap="myMap">
</collection>
</collection>
</resultMap>
<resultMap id="myMap" type="java.util.Map">
<result column="dic" property="dic"/>
</resultMap>
//查询方法
<select id="getColumnValueById" resultMap="TemplateColumnsVO">
SELECT
tc.type ,tc.column_code ,tc.label ,tc.placeholder , tc.b_required , tc.value ,tcd.value as dicValue ,tcd.name as dicName,tcd.name as dic
FROM
template_column tc
LEFT JOIN template_column_dict tcd ON tc.id = tcd.template_column_id
where tc.tamplate_id= #{templateId}
order by tc.order_by ,tcd.order_by
</select>
部分Java实体类
@Data
public class ColumnValuesVO {
private String name;
private String value;
private Map<String,Object> haha;
}
结果如图:
参考文档连接:https://www.cnblogs.com/hamhog/p/3959451.html 介绍的是map的嵌套,讲解的很清楚,谢谢作者
来源:CSDN
作者:流水随清风
链接:https://blog.csdn.net/qq_31183727/article/details/86711145