实现MyBatis批量更新

Service

        public int updateList(List<PigInfoEntity> entity);

ServiceImpl

	public int updateList(List<PigInfoEntity> entity){
		logger.info("PigInfoServiceImpl ==> updateList()");
		return pigInfoDao.updateList(entity);
		
	}

Dao 

        public int updateList(List<PigInfoEntity> entity);

DaoImpl

	@Override
	public int updateList(List<PigInfoEntity> entity){
		logger.info("PigInfoDaoImpl ==> updateList()");
		return getWriteSession().update(sqlId("updateList"),entity);		
	}

Mapper

	<update id="updateList" parameterType="java.util.List" >
	<foreach collection="list" item="item" index="index" open="" close="" separator=";">
	 update t_pig_info 
	 	<set>
	 		     update_time=now(),
			     update_user='${item.update_user}'
		</set>
		where id='${item.id}' and del_flag='0'
		    </foreach>
	</update>



猜你喜欢

转载自blog.csdn.net/qq_36014509/article/details/80987355
今日推荐