STUDY/DBMS
[MyBatis] 동적 쿼리 foreach문 문법 정리
nnh
2023. 4. 10. 18:50
728x90
< ibatis > iterate문 태그 ( ibatis : MyBatis의 옛 버전 )
property : 파라미터명
prepend : 쿼리로 쓰일 문자
open : 구문이 시작될 때 삽입할 문자열
close : 구문이 종료될 때 삽입할 문자열
conjunction : 반복되는 사이에 출력할 문자열
< MyBatis > foreach문 태그
collection : 전달받은 인자. List or Array 형태만 가능
item : 전달받은 인자값을 alias명으로 대체
open : 구문이 시작될 때 삽입할 문자열
close : 구문이 종료될 때 삽입할 문자열
separator : 반복되는 사이에 출력할 문자열
index : 반복되는 구문 번호. 0부터 순차적으로 증가
<update id="updateTest" parameterType="com.test.testCode.main.testClass.request.ReqDto">
<foreach collection="ReqDto" item="list" separator=";">
update testTable
set check = #{list.check},
updated_at = now()
where id = #{list.id}
</foreach>
</update>
728x90