• mbatis xml文件写法


    <?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE mapper PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN" "http://ibatis.apache.org/dtd/ibatis-3-mapper.dtd">
    <mapper namespace="com.bill99.acs.fmp.base.org.seashell.technical.dao.IBatchDao">
       <resultMap id="batchEo" type="com.bill99.acs.fmp.base.org.seashell.technical.model.BatchEo">
          <result property="batchId" column="BATCH_ID" />
          <result property="batchType" column="BATCH_TYPE" />
          <result property="jobId" column="JOB_ID" />
          <result property="ruleId" column="RULE_ID" />
          <result property="batchName" column="BATCH_NAME" />
          <result property="batchCode" column="BATCH_CODE" />
          <result property="totalNum" column="TOTAL_NUM" />
          <result property="totalAmount" column="TOTAL_AMOUNT" />
          <result property="memo" column="MEMO" />
          <result property="crtTime" column="CRT_TIME" />
          <result property="updTime" column="UPD_TIME" />
          <result property="channelCode" column="CHANNEL_CODE" />
       </resultMap>
    
    <!-- 全部列名 -->
        <sql id="allColumns">
        BATCH_ID,
        BATCH_TYPE,
        JOB_ID,
        RULE_ID,
        BATCH_NAME,
        BATCH_CODE,
        TOTAL_NUM,
        TOTAL_AMOUNT,
        MEMO,
        CRT_TIME,
        UPD_TIME,
        CHANNEL_CODE
        </sql>
    
    
        <!-- 公共查询条件  分页+明细 -->
        <sql id="query_where_condition">
            FROM SEASHELL.T_FMP_BATCH
            <where>
                <if test="batchId != null"> and BATCH_ID = #{batchId} </if>
                <if test="beginCrtDateTime != null">AND CRT_TIME &gt;= to_date(#{beginCrtDateTime},'yyyy-mm-dd hh24:mi:ss')</if>
                <if test="endCrtDateTime != null">AND CRT_TIME &lt;= to_date(#{endCrtDateTime},'yyyy-mm-dd hh24:mi:ss')</if>
                <if test="batchType != null"> and BATCH_TYPE = #{batchType} </if>
                <if test="jobId != null"> and JOB_ID = #{jobId} </if>
                <if test="ruleId != null"> and RULE_ID = #{ruleId} </if>
                <if test="batchName != null"> and BATCH_NAME = #{batchName} </if>
                <if test="vagueBatchName != null and vagueBatchName != ''">AND BATCH_NAME like CONCAT(CONCAT('%',#{vagueBatchName}),'%')</if>
                <if test="batchCode != null"> and BATCH_CODE = #{batchCode} </if>
                <if test="totalNum != null"> and TOTAL_NUM = #{totalNum} </if>
                <if test="totalAmount != null"> and TOTAL_AMOUNT = #{totalAmount} </if>
                <if test="memo != null"> and MEMO = #{memo} </if>
                <if test="beginCrtTime != null">AND CRT_TIME &gt;= to_date(#{beginCrtTime},'yyyy-mm-dd')</if>
                <if test="endCrtTime != null">AND CRT_TIME &lt;= to_date(#{endCrtTime},'yyyy-mm-dd')</if>
                <if test="beginUpdTime != null">AND UPD_TIME &gt;= to_date(#{beginUpdTime},'yyyy-mm-dd')</if>
                <if test="endUpdTime != null">AND UPD_TIME &lt;= to_date(#{endUpdTime},'yyyy-mm-dd')</if>
                <if test="channelCode != null"> and CHANNEL_CODE = #{channelCode} </if>
                <if test="vagueChannelCode != null and vagueChannelCode != ''"> AND CHANNEL_CODE like CONCAT(CONCAT('%',#{vagueChannelCode}),'%')</if>
                <if test="batchIds !=null and batchIds.size() !=0">
                    and BATCH_ID in
                    <foreach collection="batchIds" item="item"
                        separator="," open="(" close=")">
                        #{item}
                    </foreach>
                </if>
            </where>
        </sql>
    
        <select id="query"
            parameterType="com.bill99.acs.fmp.base.org.seashell.domain.query.BatchForQuery"
            resultMap="batchEo">
            select
            <include refid="allColumns" />
            <include refid="query_where_condition" />
            
            <if test="page!=null and page.orderField != null"> ORDER BY ${page.orderField} </if>
            <if test="page!=null and page.orderDirection != null"> ${page.orderDirection} </if>
        </select>
    </mapper>
  • 相关阅读:
    windows 10 查看电池损耗情况
    pycharm 远程显示 matplotlib
    关联矩阵与邻接矩阵 2018-11-27
    Determinats(行列式) 2018-11-23
    Ablation study 2018-11-10
    ODBC,实现图片循环写入Oracle数据库
    c#与java之比较(转自Jack.Wang's home)
    java中移位操作
    如何自学java迅速成为java高手
    一点点学习思考
  • 原文地址:https://www.cnblogs.com/wsy0202/p/13898905.html
Copyright © 2020-2023  润新知