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

项目 同时被 2 个专栏收录
56 篇文章 0 订阅
9 篇文章 0 订阅

第一步:首先在配置连接池的配置为:

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);

 

  • 1
    点赞
  • 0
    评论
  • 3
    收藏
  • 一键三连
    一键三连
  • 扫一扫,分享海报

©️2021 CSDN 皮肤主题: 撸撸猫 设计师:马嘣嘣 返回首页
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值