'ibatis or 조건 생성'에 해당되는 글 1건

  1. 2015.07.23 ibatis or 조건 생성
54.iBATIS, MyBatis/iBatis2015. 7. 23. 12:19
반응형

ex)

SELECT * FROM job where (name1 = 'key1' or name2 = 'key2') and name3 = 'key3'


-------------------------------------------------------

<select id="job" parameterClass="Map">

  SELECT *

  FROM jobs

  <dynamic prepend="WHERE">

   <isNotNull prepend="AND" removeFirstPrepend="true" open="(" close=")" >

      <isNotEmpty prepend="OR" property="key1">

         name1 = #key1#

      </isNotEmpty>

      <isNotEmpty prepend="OR" property="key2">

         name2 = #key2#

      </isNotEmpty>

     </isNotNull>

   <isNotEmpty prepend="AND" property="key3">

   name3 = #key3#

   </isNotEmpty>

  </dynamic>

 </select> 

Posted by 1010