类 ServiceImpl<M extends com.baomidou.mybatisplus.core.mapper.BaseMapper<T>,T>

java.lang.Object
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl<M,T>
所有已实现的接口:
IService<T>

public abstract class ServiceImpl<M extends com.baomidou.mybatisplus.core.mapper.BaseMapper<T>,T> extends Object implements IService<T>
IService 实现类( 泛型:M 是 mapper 对象,T 是实体 )
从以下版本开始:
2018-06-23
作者:
hubin
  • 字段详细资料

    • log

      protected final org.apache.ibatis.logging.Log log
    • baseMapper

      @Autowired protected M extends com.baomidou.mybatisplus.core.mapper.BaseMapper<T> baseMapper
    • typeArguments

      protected final Class<?>[] typeArguments
    • entityClass

      protected final Class<T> entityClass
    • mapperClass

      protected final Class<M extends com.baomidou.mybatisplus.core.mapper.BaseMapper<T>> mapperClass
  • 构造器详细资料

    • ServiceImpl

      public ServiceImpl()
  • 方法详细资料

    • getBaseMapper

      public M getBaseMapper()
      从接口复制的说明: IService
      获取对应 entity 的 BaseMapper
      指定者:
      getBaseMapper 在接口中 IService<M extends com.baomidou.mybatisplus.core.mapper.BaseMapper<T>>
      返回:
      BaseMapper
    • getEntityClass

      public Class<T> getEntityClass()
      从接口复制的说明: IService
      获取 entity 的 class
      指定者:
      getEntityClass 在接口中 IService<M extends com.baomidou.mybatisplus.core.mapper.BaseMapper<T>>
      返回:
      Class<T>
    • getSqlSessionFactory

      protected org.apache.ibatis.session.SqlSessionFactory getSqlSessionFactory()
    • retBool

      @Deprecated protected boolean retBool(Integer result)
      已过时。
      3.3.1
      判断数据库操作是否成功
      参数:
      result - 数据库操作返回影响条数
      返回:
      boolean
    • currentMapperClass

      protected Class<M> currentMapperClass()
    • currentModelClass

      protected Class<T> currentModelClass()
    • sqlSessionBatch

      @Deprecated protected org.apache.ibatis.session.SqlSession sqlSessionBatch()
      已过时。
      3.3.0
      批量操作 SqlSession
    • closeSqlSession

      @Deprecated protected void closeSqlSession(org.apache.ibatis.session.SqlSession sqlSession)
      已过时。
      3.3.0
      释放sqlSession
      参数:
      sqlSession - session
    • sqlStatement

      @Deprecated protected String sqlStatement(com.baomidou.mybatisplus.core.enums.SqlMethod sqlMethod)
      已过时。
      3.4.0
      获取 SqlStatement
      参数:
      sqlMethod - ignore
      返回:
      ignore
      另请参阅:
    • saveBatch

      @Transactional(rollbackFor=java.lang.Exception.class) public boolean saveBatch(Collection<T> entityList, int batchSize)
      批量插入
      指定者:
      saveBatch 在接口中 IService<M extends com.baomidou.mybatisplus.core.mapper.BaseMapper<T>>
      参数:
      entityList - ignore
      batchSize - ignore
      返回:
      ignore
    • getSqlStatement

      protected String getSqlStatement(com.baomidou.mybatisplus.core.enums.SqlMethod sqlMethod)
      获取mapperStatementId
      参数:
      sqlMethod - 方法名
      返回:
      命名id
      从以下版本开始:
      3.4.0
    • saveOrUpdate

      public boolean saveOrUpdate(T entity)
      TableId 注解存在更新记录,否插入一条记录
      指定者:
      saveOrUpdate 在接口中 IService<M extends com.baomidou.mybatisplus.core.mapper.BaseMapper<T>>
      参数:
      entity - 实体对象
      返回:
      boolean
    • saveOrUpdateBatch

      @Transactional(rollbackFor=java.lang.Exception.class) public boolean saveOrUpdateBatch(Collection<T> entityList, int batchSize)
      从接口复制的说明: IService
      批量修改插入
      指定者:
      saveOrUpdateBatch 在接口中 IService<M extends com.baomidou.mybatisplus.core.mapper.BaseMapper<T>>
      参数:
      entityList - 实体对象集合
      batchSize - 每次的数量
    • updateBatchById

      @Transactional(rollbackFor=java.lang.Exception.class) public boolean updateBatchById(Collection<T> entityList, int batchSize)
      从接口复制的说明: IService
      根据ID 批量更新
      指定者:
      updateBatchById 在接口中 IService<M extends com.baomidou.mybatisplus.core.mapper.BaseMapper<T>>
      参数:
      entityList - 实体对象集合
      batchSize - 更新批次数量
    • getOne

      public T getOne(com.baomidou.mybatisplus.core.conditions.Wrapper<T> queryWrapper, boolean throwEx)
      从接口复制的说明: IService
      根据 Wrapper,查询一条记录
      指定者:
      getOne 在接口中 IService<M extends com.baomidou.mybatisplus.core.mapper.BaseMapper<T>>
      参数:
      queryWrapper - 实体对象封装操作类 QueryWrapper
      throwEx - 有多个 result 是否抛出异常
    • getOneOpt

      public Optional<T> getOneOpt(com.baomidou.mybatisplus.core.conditions.Wrapper<T> queryWrapper, boolean throwEx)
      从接口复制的说明: IService
      根据 Wrapper,查询一条记录
      指定者:
      getOneOpt 在接口中 IService<M extends com.baomidou.mybatisplus.core.mapper.BaseMapper<T>>
      参数:
      queryWrapper - 实体对象封装操作类 QueryWrapper
      throwEx - 有多个 result 是否抛出异常
      返回:
      Optional 返回一个Optional对象
    • getMap

      public Map<String,Object> getMap(com.baomidou.mybatisplus.core.conditions.Wrapper<T> queryWrapper)
      从接口复制的说明: IService
      根据 Wrapper,查询一条记录
      指定者:
      getMap 在接口中 IService<M extends com.baomidou.mybatisplus.core.mapper.BaseMapper<T>>
      参数:
      queryWrapper - 实体对象封装操作类 QueryWrapper
    • getObj

      public <V> V getObj(com.baomidou.mybatisplus.core.conditions.Wrapper<T> queryWrapper, Function<? super Object,V> mapper)
      从接口复制的说明: IService
      根据 Wrapper,查询一条记录
      指定者:
      getObj 在接口中 IService<M extends com.baomidou.mybatisplus.core.mapper.BaseMapper<T>>
      参数:
      queryWrapper - 实体对象封装操作类 QueryWrapper
      mapper - 转换函数
    • executeBatch

      @Deprecated protected boolean executeBatch(Consumer<org.apache.ibatis.session.SqlSession> consumer)
      已过时。
      3.3.1 后面我打算移除掉 executeBatch(Collection, int, BiConsumer) }.
      执行批量操作
      参数:
      consumer - consumer
      从以下版本开始:
      3.3.0
    • executeBatch

      protected <E> boolean executeBatch(Collection<E> list, int batchSize, BiConsumer<org.apache.ibatis.session.SqlSession,E> consumer)
      执行批量操作
      类型参数:
      E - 泛型
      参数:
      list - 数据集合
      batchSize - 批量大小
      consumer - 执行方法
      返回:
      操作结果
      从以下版本开始:
      3.3.1
    • executeBatch

      protected <E> boolean executeBatch(Collection<E> list, BiConsumer<org.apache.ibatis.session.SqlSession,E> consumer)
      执行批量操作(默认批次提交数量IService.DEFAULT_BATCH_SIZE
      类型参数:
      E - 泛型
      参数:
      list - 数据集合
      consumer - 执行方法
      返回:
      操作结果
      从以下版本开始:
      3.3.1
    • removeById

      public boolean removeById(Serializable id)
      从接口复制的说明: IService
      根据 ID 删除
      指定者:
      removeById 在接口中 IService<M extends com.baomidou.mybatisplus.core.mapper.BaseMapper<T>>
      参数:
      id - 主键ID
    • removeByIds

      @Transactional(rollbackFor=java.lang.Exception.class) public boolean removeByIds(Collection<?> list)
      从接口复制的说明: IService
      删除(根据ID 批量删除)
      指定者:
      removeByIds 在接口中 IService<M extends com.baomidou.mybatisplus.core.mapper.BaseMapper<T>>
      参数:
      list - 主键ID或实体列表
    • removeById

      public boolean removeById(Serializable id, boolean useFill)
      从接口复制的说明: IService
      根据 ID 删除
      指定者:
      removeById 在接口中 IService<M extends com.baomidou.mybatisplus.core.mapper.BaseMapper<T>>
      参数:
      id - 主键(类型必须与实体类型字段保持一致)
      useFill - 是否启用填充(为true的情况,会将入参转换实体进行delete删除)
      返回:
      删除结果
    • removeBatchByIds

      @Transactional(rollbackFor=java.lang.Exception.class) public boolean removeBatchByIds(Collection<?> list, int batchSize)
      从接口复制的说明: IService
      批量删除(jdbc批量提交)
      指定者:
      removeBatchByIds 在接口中 IService<M extends com.baomidou.mybatisplus.core.mapper.BaseMapper<T>>
      参数:
      list - 主键ID或实体列表
      batchSize - 批次大小
      返回:
      删除结果
    • removeBatchByIds

      @Transactional(rollbackFor=java.lang.Exception.class) public boolean removeBatchByIds(Collection<?> list, int batchSize, boolean useFill)
      从接口复制的说明: IService
      批量删除(jdbc批量提交)
      指定者:
      removeBatchByIds 在接口中 IService<M extends com.baomidou.mybatisplus.core.mapper.BaseMapper<T>>
      参数:
      list - 主键ID或实体列表
      batchSize - 批次大小
      useFill - 是否启用填充(为true的情况,会将入参转换实体进行delete删除)
      返回:
      删除结果