關於mybatis中批量插入和批量查詢的sql語句查詢
阿新 • • 發佈:2019-01-27
批量查詢
<select id="findJobInfoByIds" parameterType="java.util.List" resultType="jobInfoDO"> <include refid="jobinfo-select-common"/> from job_info WHERE status = 1 and id in <foreach collection="list" index="index" item="item" open="(" close=")" separator=","> #{item} </foreach></select>
批量插入:
<!-- 批量插入 --> <insert id="insertBatchJobInstance" parameterType="List" useGeneratedKeys="true" keyProperty="id"> insert into job_instance (gmt_create,gmt_modified, job_instance_no, job_instance_version, job_id, job_name, job_group_id, job_type, cron_express, job_schedule_cycle, job_schedule_type, job_instance_type, job_info, realtime, job_time,execute_param,start_execute_time,end_execute_time,submit_time,execute_status,execute_log_url,status,extend,running_type) values <foreachcollection="list" item="item" index="index" separator=","> (now(), now(), #{item.jobInstanceNo}, #{item.jobInstanceVersion}, #{item.jobId}, #{item.jobName}, #{item.jobGroupId}, #{item.jobType}, #{item.cronExpress}, #{item.jobScheduleCycle}, #{item.jobScheduleType}, #{item.jobInstanceType}, #{item.jobInfo}, #{item.realtime}, #{item.jobTime}, #{item.executeParam}, #{item.startExecuteTime}, #{item.endExecuteTime}, #{item.submitTime}, #{item.executeStatus}, #{item.executeLogUrl}, 1, #{item.extend},#{item.runningType}) </foreach></insert>