Mybatis的分支選擇和In循環


Mybatis的分支選擇:

<choose>
   <when test="patientNo != null and patientNo != ''">
      and ipi.patient_no = #{patientNo}
   </when>
   <otherwise>
      <if test="patientName != null and patientName != ''">
         and ipi.patient_name like CONCAT('%',#{patientName},'%')
      </if>
      <trim prefix="where" prefixOverrides="and">
         <if test="printTimeBegin != null and printTimeBegin != ''">
            and mrm.print_time >= #{printTimeBegin}
         </if>
         <if test="printTimeEnd != null and printTimeEnd != ''">
            and mrm.print_time  &lt;=  #{printTimeEnd}
         </if>
      </trim>
   </otherwise>
</choose>

循環In:

<if test='depts!=null and depts.size()>0'>
   and ioh.department_id IN
   <foreach item="item" index="index" collection="depts" open="(" separator="," close=")">
      #{item}
   </foreach>
</if>


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM