日期:2014-05-17 浏览次数:20687 次
<select id="searchItem" parameterClass="model" resultClass="item">
<![CDATA[
select
distinct i.*
from item i left join itemcolor c on i.mjid = c.mjid left join itemsize s on i.mjid = s.mjid
]]>
<include refid="wheresql" />
<![CDATA[
order by i.makerid,i.brandid,i.mjid
]]>
</select>
<!-- 结果集映射,根据groupBy属性值捕获数据封装对象 -->
<resultMap class="person" id="get_person_result" groupBy="cardId">
<result property="cardId" column="cardId" />
<result property="name" column="name" />
<result property="age" column="age" />
<result property="sex" column="sex" />
<!-- 引用另一个结合集映射,必须显式使用命名空间前缀 -->
<result property="books" resultMap="Person.get_book_result" />
</resultMap>
<resultMap class="book" id="get_book_result">
<result property="bid" column="bid" />
<result property="bname" column="bname" />
<result property="person.cardId" column="pid" />
<result property="date" column="date" />
</resultMap>
<!-- 多表联查 -->
<select id="getFullPersonById" parameterClass="int"
resultMap="get_person_result">
select * from person p left join book b on
p.cardId=b.pid where p.cardId=#cardId#
</select>