1、例子:
实体类:
<select id="findAllMsgByTagId" parameterType="com.yunkuan.entity.ParkClass" resultMap="parkMap" >
select * from parkclass pc join parkclasstag pct on(pc.classtaglevel=pct.id)
join parent p on(pc.parentid=p.id)
where pc.parkid=#{parkid} and pct.id=#{classtaglevel}
</select>
<!-- 指定关联属性加载 -->
<resultMap id="parkMap" type="com.yunkuan.entity.ParkClassParent">
<id property="id" column="id"/>
<result property="parkid" column="parkid"/>
<result property="childname" column="childname"/>
<result property="classtaglevel" column="classtaglevel"/>
<result property="parentid" column="parentid"/>
<result property="timer" column="timer"/>
ParkClassTag类:
<association property="parkClassTag" javaType="com.yunkuan.entity.ParkClassTag">
<id property="id" column="id"/>
<result property="id" column="id"/>
<result property="tagname" column="tagname"/>
<result property="timer" column="timer"/>
</association>
Parent类:
<association property="parent" javaType="com.yunkuan.entity.Parent">
<id property="id" column="id"/>
<result property="parentname" column="parentname"/>
<result property="parentpass" column="parentpass"/>
<result property="phone" column="phone"/>
<result property="address" column="address"/>
<result property="balance" column="balance"/>
<result property="timer" column="timer"/>
</association>
</resultMap>
如果多表查询里有相同的字段:
例子: