<typeAlias >标签用于定义类别名
如:<typeAliasalias="users" type="com.map.UserObj"/>
关联查询使用<association>标签:
两种方式:
一:<association property="husband" javaType="HusbandBean">
<result property="id" column="hid" javaType="java.lang.Integer"/>
<result property="husbandName" column="hhusband" javaType="java.lang.String"/>
</association>
二:<association property="husband" column="fk_husband_id" select="com.lovo.my.dao.IHusbandMapper.getHusbandBeanById" javaType="HusbandBean"/>
使用时:引用<resultMap>的id即可。
代码如下:
一:<select id="queryWifeAndHusband" resultMap="wifeAndHusbandMap">
select w.id as wid,w.wife as wwife,h.id as hid,h.husband as hhusband from t_wife as w,t_husband as h where h.id = w.fk_husband_id and w.id = #{id}
</select>
二:<select id="queryWifeAndHusband" resultMap="wifeAndHusbandMap">
select * from t_wife where id = #{id}
</select>
批量操作和foreach标签
<deleteid="delMore">
delete from t_user where u_id in(
<foreach collection="ids"item="id" separator=",">
#{id}
</foreach>
)
</delete>
<selectid="dynaFindUser" resultMap="user">
select * from t_user where 1=1
<iftest="id != 0">
and u_id > #{id}
</if>
<if test="userName != null and userName != ''">
and u_userName like '%${userName}%'
</if>
</select>