Mybatis-plus---的批量插入


批量插入

一、继承IService(伪批量)

二、insertBatchSomeColumn


Mybatis-plus很强,为我们诞生了极简CURD操作,但对于数据批量操作,显然默认提供的insert方法是不够看的了,于是它和它来了!!! Mybatis-plus提供的两种插入方式

        继承IService(伪批量)

        insertBatchSomeColumn 

一、继承IService(伪批量)

在Mapper继承BaseMapper<T>

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.demo.entity.UserStudy;
import org.apache.ibatis.annotations.Mapper;

@Mapper
public interface UserStudyMapper extends BaseMapper<UserStudy> {
}

在Service中继承IService<T>

import com.baomidou.mybatisplus.extension.service.IService;
import com.example.demo.entity.UserStudy;

/********************************************************************************
 ** @author : ZYJ
 ** @date :2023/04/20
 ** @description :厂长老婆催的睡觉了-批量插入Service
 *********************************************************************************/
public interface UserStudyService extends IService<UserStudy> {

}

在Service实现类继承ServiceImpl<M,T>

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.demo.entity.UserStudy;
import com.example.demo.mapper.UserStudyMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**************************
评论 22
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值