1、可以将这部分移到专门的mapper.xml中,比如common.xml
<mapper namespace="Common">
<sql id="Common.pagingStart">
</sql>
<sql id="Common.pagingEnd">
<![CDATA[ limit #{startWith,jdbcType=INTEGER},
#{rows,jdbcType=INTEGER} ]]>
</sql>
</mapper>
2、在具体的mapper.xml可以通过namespace进行引用
<select id="queryPage" resultMap="clientPage"
parameterType="java.util.Map">
<include refid="Common.pagingStart"/>
<include refid="commonSelect"/>
<include refid="commonFrom"/>
<include refid="commonWhere"/>
<if test="clientId != null" >
and CLIENT_ID = #{clientId,jdbcType=VARCHAR}
</if>
<if test="clientName != null" >
and CLIENT_NAME like '%${clientName}'
</if>
<if test="telephone != null" >
and TELEPHONE = #{telephone,jdbcType=VARCHAR}
</if>
order by client_id
<include refid="Common.pagingEnd"/>
</select>
网友评论