mybatis批量操作数据
批量查询语句:
List<MoiraiProductResource> selectBatchInfo(List<Long> idList);
<!-- 批量查询 --> <select id="selectBatchInfo" parameterType="java.util.List" resultMap="BaseResultMap"> select <include refid="Base_Column_List"/> from moirai_product_resource WHERE PRODUCT_ID IN <foreach collection="list" open="(" close=")" separator="," item="item" index="index"> #{item} </foreach> </select>
批量插入:
int insertBatchInfo(List<MoiraiProductResource> listMoiraiProductResource);
<!-- 批量添加 --> <insert id="insertBatchInfo" parameterType="java.util.List"> insert into moirai_product_resource (PRODUCT_RESOURCE_ID, PRODUCT_ID, RESOURCE_ID, CREATETIME, CREATER) values <foreach collection="list" item="item" index="index" separator="," > (#{item.productResourceId,jdbcType=BIGINT}, #{item.productId,jdbcType=BIGINT}, #{item.resourceId,jdbcType=BIGINT}, #{item.createtime,jdbcType=BIGINT}, #{item.creater,jdbcType=VARCHAR}) </foreach> </insert>