우선, MyBatis 버전을 반환하기 위해 레코드를 삽입하려면 낮은 점수가 필요하지만 기본 키가있는 배치 삽입 리턴은 버전 3.3.1로 업그레이드해야하며 3.3.0 이전에는 불가능합니다.
<pectionency> <groupid> org.mybatis </groupid> <artifactid> mybatis-spring </artifactid> <버전> 3.3.1 </version> </fectionency>
1.mysql
<insert id = "insertBybatch"useGenerateKeys = "true"keyproperty = "id"parametertype = "java.util.list"> test에 삽입 (sblsh, xh, jsjg, is_success, is_display, gmt_create, gmt_modify, create) < "voreach =" ""값) 인덱스 = "index"separator = ","> ( #{item.sblsh, jdbctype = bigint}, #{item.xh, jdbctype = char}, #{item.jsjg, jdbctype = bigint}, #{item.issuccess, jdbctype = tinyint}, #{item.isdisplay, jdbctype = tinyint}, sysdate (), sysdate (), #{item.createuser, jdbctype = varchar}) </foreach> </insert>genderatedKeys = "true"keyProperty = "기본 키 필드"사용
2. 오라클
<insert id = "insertbatch"> <selectkey keyProperty = "id"resultType = "long"order = "order"> select test.nextVal은 dual </selectkey> id as is as test </selectkey> test (id, value, gmt_create, gmt_modified) select test.nextval, a. 선택 #{item.value, jdbctype = varchar}, #{item.gmtcreate, jdbctype = date}, #{item.gmtModified, jdbctype = date} a </foreach>) a </insert>위의 기사 Mybatis 삽입 또는 배치 삽입은 자체 성장 기본 키 레코드가있는 예제를 반환합니다. 나는 당신이 당신에게 참조를 줄 수 있기를 바랍니다. 그리고 당신이 wulin.com을 더 지원할 수 있기를 바랍니다.