ก่อนอื่นการแทรกบันทึกเพื่อส่งคืนเวอร์ชัน mybatis ต้องใช้จุดต่ำในขณะที่แบทช์การแทรกผลตอบแทนด้วยปุ่มหลักต้องมีการอัพเกรดเป็นเวอร์ชัน 3.3.1 และก่อน 3.3.0 ไม่มีใครสามารถทำได้
<การพึ่งพา> <roupId> org.mybatis </groupId> <ratifactid> mybatis-spring </artifactid> <version> 3.3.1 </version>
1.MYSQL
<insert id = "InsertByBatch" useGeneratedKeys = "true" keyProperty = "id" parameterType = "java.util.list"> แทรกลงในการทดสอบ (sblsh, xh, jsjg, is_success, is_display, gmt_create, gmt_mod index = "index" separator = ","> ( #{item.sblsh, jdbctype = bigint}, #{item.xh, jdbctype = char}, #{item.jsjg, jdbctype = bigint}, #{item.issuccess #{item.isdisplay, jdbcType = tinyInt}, sysdate (), sysdate (), #{item.createUser, jdbcType = varchar}) </foreach> </insert>ใช้ generatedKeys = "true" keyProperty = "ฟิลด์คีย์หลัก"
2. หรือ
<insert id = "InsertBatch"> <selectKey keyProperty = "id" resultType = "long" order = "ก่อน"> เลือก test.nextVal เป็น id จาก dual </selectkey> แทรกลงในการทดสอบ (id, value, gmt_create, gmt_modified) เลือก test.nextval เลือก #{item.value, jdbcType = varchar}, #{item.gmtcreate, jdbcType = วันที่}, #{item.gmtmodified, jdbcType = วันที่} จากคู่ </foreach>)บทความข้างต้นการแทรก mybatis หรือการแทรกแบทช์ส่งคืนตัวอย่างด้วยบันทึกคีย์หลักที่เติบโตด้วยตนเองคือเนื้อหาทั้งหมดที่ฉันแบ่งปันกับคุณ ฉันหวังว่าคุณจะให้ข้อมูลอ้างอิงและฉันหวังว่าคุณจะสนับสนุน wulin.com มากขึ้น