[ibatis] delete sql in 사용
prepend : 쿼리로 쓰여질 문자.
property : 파라미터명.
open : 시작 문자.
close : 종료 문자.
conjunction : 구분자.
======================================================================================
List list = new ArrayList();
list.add("A");
list.add("B");
list.add("C");
HashMap map = new HashMap();
map.put("idList", list);
======================================================================================
<select id="test" parameterClass="java.util.HashMap" resultMap="java.util.HashMap">
SELECT TITLE , CONTENT
FROM TEX_BULLETIN_H
WHERE ID
<iterate prepend="IN" property="idList" open="(" close=")" conjunction=",">
#idList[]#
</iterate>
</select>
======================================================================================
* 도메인으로 받을 때
<delete id="deleteFavorite" parameterClass="favorite">
DELETE FROM ...
WHERE favorite_id IN
<iterate property="favoriteIds" open="(" conjunction="," close=")">
<![CDATA[
#favoriteIds[]#
]]>
</iterate>
AND user_id = #userId#
</delete>
* 리스트로 받을 때
<delete id="deleteFavorite" parameterClass="java.util.List">
DELETE FROM ...
WHERE favorite_id IN
<iterate open="(" conjunction="," close=")">
<![CDATA[
#[]#
]]>
</iterate>
AND user_id = #userId#
</delete>
[ibatis] delete sql in 사용
'programming > ibatis mybatis' 카테고리의 다른 글
[ibatis] in 조건 생성하기 (0) | 2013.10.17 |
---|---|
[ibatis] in 조건으로 delete 하기 (0) | 2013.10.02 |
[ibatis] sql문 예제5 procedure (0) | 2013.06.25 |
[ibatis] sql문 예제4 update (0) | 2013.06.25 |
[ibatis] sql문 예제3 delete (0) | 2013.06.25 |