자바/iBatis
<iterator> 태그 사용하기
finkle
2008. 2. 12. 16:46
xxxxDao.java 에서 ....
List tempList = new ArrayList();
tempList.add("1001");
tempList.add("1002");
new HashMap().put("listId", tempList);
xxxx-sqlmap.xml 에서 ....
<select id="someList" resultClass="someBean" parameterClass="java.util.Map">
.... 생략 ....
AND SAMPLE_CD IN
<iterate prepend="" property="listId" open="(" close=")" conjunction=", ">
#listId[]#
</iterate>
※ 참고
List tempList = new ArrayList();
tempList.add("1001");
tempList.add("1002");
new HashMap().put("listId", tempList);
xxxx-sqlmap.xml 에서 ....
<select id="someList" resultClass="someBean" parameterClass="java.util.Map">
.... 생략 ....
AND SAMPLE_CD IN
<iterate prepend="" property="listId" open="(" close=")" conjunction=", ">
#listId[]#
</iterate>
※ 참고
prepend - the statement에 붙을 오버라이딩 가능한 SQL부분 (옵션)
property - 반복되기 위한 java.util.List타입의 프로퍼티 (필수)
open - 반복의 전체를 열기 위한 문자열, 괄호를 위해 유용하다. (옵션)
close - 반복의 전체를 닫기 위한 문자열, 괄호를 위해 유용하다. (옵션)
conjunction - 각각의 반복 사이에 적용되기 위한 문자열, AND 그리고 OR을 위해 유용하다. (옵션)
property - 반복되기 위한 java.util.List타입의 프로퍼티 (필수)
open - 반복의 전체를 열기 위한 문자열, 괄호를 위해 유용하다. (옵션)
close - 반복의 전체를 닫기 위한 문자열, 괄호를 위해 유용하다. (옵션)
conjunction - 각각의 반복 사이에 적용되기 위한 문자열, AND 그리고 OR을 위해 유용하다. (옵션)