单个:
<insert id="create" parameterType="com.dto.Cou" useGeneratedKeys="true" keyProperty="id"> insert into t ( batch_number ) values ( #{batchNumber,jdbcType=VARCHAR} ) </insert>
通过 对象. get获取
批量插入
<insert id="createBatch" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id"> insert into t (id, batch_number ) values <foreach collection="list" item="item" index="index" separator=","> ( null, #{item.batchNumber,jdbcType=VARCHAR} ) </foreach> </insert>
获取
cMapper.createBatch(cList); cList.stream().forEach(cou->{ log.debug("cou:" + cou.getId() ); });