标签:com 连接 color 定义 vat select res 关系 map
<mapper namespace="com.abc.dao.IHusbandDao"> <!-- 多表连接查询 --> <!-- 定义结果映射关系 --> <resultMap type="Husband" id="husbandMap"> <id column="hid" property="hid" /> <result column="hname" property="hname" /> <association property="wife" javaType="Wife"> <id column="wid" property="wid" /> <result column="wname" property="wname" /> </association> </resultMap> <select id="selectHusbandById" resultMap="husbandMap"> select hid,hname,wid,wname from husband,wife where wid=wifeId and hid=#{xxx} </select> </mapper>
<mapper namespace="com.abc.dao.IHusbandDao"> <!-- 多表单独查询 --> <select id="selectWifeByHusband" resultType="Wife"> select wid,wname from wife where wid=#{jjj} </select> <!-- 定义结果映射关系 --> <resultMap type="Husband" id="husbandMap"> <id column="hid" property="hid" /> <result column="hname" property="hname" /> <association property="wife" javaType="Wife" select="selectWifeByHusband" column="wifeId"/> </resultMap> <select id="selectHusbandById" resultMap="husbandMap"> select hid,hname,wifeId from husband where hid=#{xxx} </select> </mapper>
<!-- 多表连接查询 --> <!-- 定义结果映射关系 --> <resultMap type="Husband" id="husbandMap"> <id column="hid" property="hid" /> <result column="hname" property="hname" /> <association property="wife" javaType="Wife"> <id column="wid" property="wid" /> <result column="wname" property="wname" /> </association> </resultMap> <select id="selectHusbandById" resultMap="husbandMap"> select hid,hname,wid,wname from husband,wife where wid=hid and hid=#{xxx} </select>
<mapper namespace="com.abc.dao.IHusbandDao"> <!-- 多表单独查询 --> <select id="selectWifeByHusband" resultType="Wife"> select wid,wname from wife where wid=#{jjj} </select> <!-- 定义结果映射关系 --> <resultMap type="Husband" id="husbandMap"> <id column="hid" property="hid" /> <result column="hname" property="hname" /> <association property="wife" javaType="Wife" select="selectWifeByHusband" column="hid"/> </resultMap> <select id="selectHusbandById" resultMap="husbandMap"> select hid,hname from husband where hid=#{xxx} </select> </mapper>
标签:com 连接 color 定义 vat select res 关系 map
原文地址:https://www.cnblogs.com/csslcww/p/9912340.html