第一步:首先在配置连接池的配置为:
d1.url=jdbc:mysql://xxx:3306/djtms?useUnicode=true&characterEncoding=UTF8&allowMultiQueries=true
第二步:
<resultMap id="longMap" type="Long"/>
<resultMap id="baseResultMap2" type="map"/>
<select id="getPage" resultMap="baseResultMap2,longMap" resultSets="items,count">
select
SQL_CALC_FOUND_ROWS
<include refid="Base_Column_List"/>
from t_area_open
<where>
<if test="queryParam != null">
<if test="queryParam.rowid != null">
and `rowid` = #{ queryParam.rowid,jdbcType=INTEGER }
</if>
<if test="queryParam.fid != null">
and fid = #{ queryParam.fid,jdbcType=VARCHAR }
</if>
<if test="queryParam.fprovinceName != null">
and fprovince_name = #{ queryParam.fprovinceName,jdbcType=VARCHAR }
</if>
<if test="queryParam.fprovinceCode != null">
and fprovince_code = #{ queryParam.fprovinceCode,jdbcType=TINYINT }
</if>
<if test="queryParam.fcityName != null">
and fcity_name = #{ queryParam.fcityName,jdbcType=VARCHAR }
</if>
<if test="queryParam.fcityCode != null">
and fcity_code = #{ queryParam.fcityCode,jdbcType=SMALLINT }
</if>
<if test="queryParam.fcountyName != null">
and fcounty_name = #{ queryParam.fcountyName,jdbcType=VARCHAR }
</if>
<if test="queryParam.fcountyCode != null">
and fcounty_code = #{ queryParam.fcountyCode,jdbcType=INTEGER }
</if>
<if test="queryParam.fstatus != null">
and fstatus = #{ queryParam.fstatus,jdbcType=INTEGER }
</if>
<if test="queryParam.fcreatetime != null">
and fcreatetime = #{ queryParam.fcreatetime,jdbcType=TIMESTAMP }
</if>
<if test="queryParam.fupdatetime != null">
and fupdatetime = #{ queryParam.fupdatetime,jdbcType=TIMESTAMP }
</if>
<if test="queryParam.foperator != null">
and foperator = #{ queryParam.foperator,jdbcType=VARCHAR }
</if>
</if>
</where>
limit
#{offset},#{rows};
SELECT FOUND_ROWS() AS COUNT;
</select>
Dao层接口是:
public Collection<Collection<?>> getPage(@Param("queryParam") T t, @Param("offset") int offset, @Param("rows") int rows);