foreach 문은 list나 array만 된다.
* ArrayList의 예제
in java
ArrayList<String> myList= new ArrayList<String>();
in xml
<select id = "id" parameterType="String", resultType="com.whiteduck.test.vo.TextVO">
select * from test.Text
where id in
<foreach collection="myList" item="item" index="index" separator="," open="(" close=")">
#{item.value}
</foreach>
</select>
* 설명
collection = 전달받은 인자값
item = 전달받은 인자값을 다른이름으로 대체
open 해당 구문이 시작할 때
close 해당구문이 끝날 때
separator 한번 이상 반복할때 반복되는 사이에 해당 문을 넣어줌
참고 : http://pcdate.blogspot.kr/2013/05/mybatis-foreach.html
반응형
'DB Story' 카테고리의 다른 글
[ Mybatis ] Type handler was null on parameter mapping for property '__frch_item_0.value'. (3) | 2016.10.18 |
---|---|
[ Mybatis ] the content of elements must consist of well-formed character data or markup (0) | 2016.09.08 |
[ RRD ] rrd graph y-aixs unit (0) | 2016.06.29 |
[ Mysql ] 특정 필드명 보기 (0) | 2016.05.04 |
[ RRD ] 데이터 저장 기간 설정하기 (0) | 2016.04.21 |
[ DB ] execute / executeQuery / executeUpdate 차이 (0) | 2016.01.29 |
[ DB ] INSERT 데이터 삽입 (0) | 2016.01.29 |
[ DB ] DB 테이블 연산자 - JOIN 연산자 (두 개 이상 테이블 간의 비교검색) (0) | 2016.01.29 |