반응형
Notice
Recent Posts
Recent Comments
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
Tags
- docker compose mysql
- netflix oss
- mybatis
- weblogic 10
- ChannelPipeline
- jmeter
- argo cd
- coalesce
- KAFKA
- spring cloud
- Redis Sentinel
- RabbitMQ
- Netty
- cassandra
- Hibernate
- spring boot
- WebLogic
- Airflow
- redis
- Selenium
- JPA
- Spring Open Feign
- spring boot redis
- QueryDSL
- grafana
- MySQL
- docker-compose
- docker
- vue.js
- Docker Compose
Archives
- Today
- Total
IT.FARMER
mybatis 문법 foreach 본문
반응형
mybatis 문법 foreach
리스트객체로 보낼경우 parameterType="java.util.List" , collection = "list"로 받아서 처리 한다.
- item 은 el tag 안에서 사용할 변수명
this.jobMapper.findAllByJobId(List.of(masterJobId)
<select id="findAllByJobId" parameterType="java.util.List" resultType="com.cjenm.report.library.domain.entity.JobEntity">
SELECT
`job_execution_id`,
`master_job_id` as `job_id`,
`job_name`,
`total_size`,
`processed_count`,
`start_time`,
`end_time`,
`status`,
`exit_status`,
`message`,
`request_details`,
`requester`,
`last_update`
FROM `ae_report`.`master_job_management`
WHERE 1=1
AND `master_job_id` in
<foreach item="jobIds" collection="list" open="(" close=")" separator=",">
#{jobIds}
</foreach>
</select>
Map 객체 안에 Object로 보내는 경우 collection="masterJobIds" 와 같이 Parameter key 값을 적어 준다.
- parameterKey 값과 collection 의 값이 일치 하도록 한다.
- item 은 el tag 안에서 사용할 변수명
Map<String,Object> parameter = new HashMap<>();
parameter.put("jobEntity",jobEntity);
parameter.put("masterJobIds",List.of(jobId));
parameter.put("jobExecutionId", jobExecutionId);
<update id="updateStatus" parameterType="Map">
UPDATE `ae_report`.`master_job_management`
SET
`status` = #{jobEntity.status},
`processed_count` = #{jobEntity.processedCount},
`last_update` = #{jobEntity.lastUpdate}
WHERE 1=1
<if test="jobExecutionId != null and jobExecutionId != ''">
AND job_execution_id = #{jobExecutionId}
</if>
AND `master_job_id` in
<foreach item="jobIds" collection="masterJobIds" open="(" close=")" separator=",">
#{jobIds}
</foreach>
AND status = 'RUNNING';
</update>
반응형
'Spring > Spring Data JPA' 카테고리의 다른 글
mybatis Cause: java.lang.IllegalArgumentException: argument type mismatch” (0) | 2021.04.29 |
---|---|
mybatis association, inner class , embeded (0) | 2021.04.29 |
JPA Inner Join , left join (0) | 2020.09.08 |
JPA paging 속성 (0) | 2020.07.23 |
QueryDsl Mysql DATE_ADD, ADDDATE (0) | 2020.05.26 |