반응형
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 |
Tags
- JPA
- spring boot redis
- WebLogic
- netflix oss
- spring boot
- RabbitMQ
- ChannelPipeline
- Netty
- spring cloud
- coalesce
- Selenium
- redis
- Hibernate
- Docker Compose
- vue.js
- QueryDSL
- mybatis
- Redis Sentinel
- docker-compose
- jmeter
- Spring Open Feign
- docker
- cassandra
- weblogic 10
- Airflow
- docker compose mysql
- KAFKA
- MySQL
- grafana
- argo cd
Archives
- Today
- Total
IT.FARMER
mybatis 문법 foreach 본문
반응형
리스트객체로 보낼경우 parameterType="java.util.List" , collection = "list"로 받아서 처리 한다.
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 `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 값을 적어 준다.
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 `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>
반응형
'DataBase' 카테고리의 다른 글
무료 ERD 추천 (0) | 2021.11.22 |
---|---|
Aerospike (0) | 2018.04.09 |
MSSQL LPAD (0) | 2011.03.25 |