问题描述
一般resultMap配置的字段都是来自一张表,如果有多张表,还可以用吗,求解? 问题补充:resultMap集合里的数据来自多张表
解决方案
不明白楼主什么意思 <resultMap id="pagebean" type="PageBean"> <id column="id" property="id"/> <result column="uri" property="uri"/> <result column="title" property="title"/> <result column="generate" property="generate" javaType="boolean"/> <result column="siteid" property="siteid"/> <association property="config" column="configid" javaType="ConfigBean"> <id property="id" column="cfg_id"/> <result property="domain" column="cfg_domain"/> <result property="folder" column="folder"/> <result property="keywordfile" column="keywordfile"/> <result property="innerlinkcount" column="innerlinkcount"/> <result property="outerlinkcount" column="outerlinkcount"/> <result property="siteid" column="cfg_siteid"/> <result property="template" column="template"/> </association> </resultMap> <select id="listUngeneratedPages" resultMap="pagebean"> select p.*, c.id cfg_id, c.keywordfile, c.siteid cfg_siteid, c.folder folder, c.template template, c.innerlinkcount innerlinkcount, c.outerlinkcount outerlinkcount, s.domain cfg_domain from biz_page p left join biz_generateconfig c on c.id=p.configid left join biz_site s on p.siteid=s.id where p.generate=0 </select>举个栗子,这就是3张表关联查询,PageBean里面还包含一个ConfigBean的一对一关联关系