티스토리 뷰

java

ibatis 동적쿼리 지원태그

미스테리아 2018. 12. 28. 14:59

가끔 헷갈릴때가 있으니 정리해두자..

잘 정리해둔분이 있어서 퍼왔다..


1.  속성 


prepend – statement에 붙을 오버라이딩 가능한 SQL부분(옵션) 

property – 비교되는 프로퍼티(필수) 

compareProperty – 비교되는 다른 프로퍼티(필수 또는 compareValue) 

compareValue – 비교되는 값(필수 또는 compareProperty) 



<isNull> : null인지 체크 

<isNotNull> : null이 아닌지 체크 


<isEqual> : 같은지 체크. 

<isNotEqual> : 같지 않은지 체크. 


<isEmpty> : null 이거나 empty("" or size()<1) 인지 체크 

<isNotEmpty> : null 아니거나 empty("" or size()<1) 아닌지 체크 


<isGreaterThan> : 큰지 체크. (>) 

<isGreaterEqual> : 크거나 같은지 체크. (>=) 


<isLessThan> : 작은지 체크.  (<) 

<isLessEqual>  : 작거나 같은지 체크. (<=) 


 [출처] ibatis 동적쿼리 지원 태그|작성자 Gabriel


2. 사용예제


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

  <isEqual  property="seq"  compareValue="1">

    seq = #seq # 

   </isEqual>

 <isGreaterThan property="seq _size"  compareValue="1">seq in 

 <iterate property="seq " open="(" close=")" conjunction=",">

#seq []#

</iterate>

    </isGreaterThan>

</isNotEmpty>



3. 페이징시 <= 문자열 인식시 

  WHERE ROWNUM <![CDATA[<=]]> COALESCE(#cnt#, 0)

'java' 카테고리의 다른 글

한글이 깨질때 체크리스트  (0) 2019.03.12
댓글