您的位置:首页 > 数据库

mybatis一个select标签执行多个sql语句

2018-01-03 14:23 459 查看
第一步:首先在配置连接池的配置为
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>
接口为:
public Collection<Collection<?>> getPage(@Param("queryParam") T t, @Param("offset") int offset, @Param("rows") int rows);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: