每次写mybatis 级联查询 就要写 几个 resultmap 一堆参数 ,sql也要把用到 的字段全部拼出来。
一直对mabatis 的用法不甚了解 到底用不用 这么麻烦
<resultMap id="CommodityResult" type="com.ronhan.ctoc.model.Commodity">
<id column="c_id" jdbcType="BIGINT" property="id" />
<result column="c_skuid" jdbcType="VARCHAR" property="skuid" />
<result column="c_state" jdbcType="TINYINT" property="state" />
<result column="c_imageUrl" jdbcType="VARCHAR" property="imageUrl" />
<result column="c_saleprice" jdbcType="DECIMAL" property="salePrice" />
</resultMap>
<select id="showOfferList" parameterType="map" resultMap="offerResult" >
select o.*,c.state as c_state , c.id as c_id ,c.skuid as c_skuid ,c.imageUrl as c_imageUrl,c.salePrice as c_saleprice,m.messages as m_messages
from m_message m , o_offer o left join c_commodity c on o.commodity_id =c.id left join o_offerhistroy oh on o.id=oh.offer_id
where 1=1 and oh.message_id= m.id
<if test="data.skuid!= null">
and c.skuid LIKE '%${data.skuid}%'
</if>
<if test="data.status!=null">
and o.status =#{data.status}
</if>
<if test="data.startTime!=null">
and o.createDate >#{data.startTime}
</if>
<if test="data.endTime!=null">
and o.createDate < #{data.endTime}
</if>
limit ${page.start},${page.rowsPerPage}
就一个查询 写这么一大堆 , 请问下 哪里可以优化一点吗?