行业知识
Mybatis-plus中BaseMapper具体方法说明
2026-12-06 09:44:00
来源:互联网转载
一、BaseMapper方法详解
1、Insert
()// 插入一条记录int insert(T entity);
2、Delete
// 根据 entity 条件,删除记录int delete(@Param(Constants.WRAPPER) Wrapper wrapper);// 删除(id集合 批量删除,不能为 null 以及 empty)——例如参数为:List idList;int deleteBatchIds(idList);// 根据 ID 删除int deleteById(id);// 根据 columnMap 条件,删除记录int deleteByMap(@Param(Constants.COLUMN_MAP) Map columnMap);
3、Update
()// 根据 whereEntity 条件,更新记录int update(@Param(Constants.ENTITY) T entity, @Param(Constants.WRAPPER) Wrapper updateWrapper);// 根据 ID 修改,实体中set id参数,然后将实体直接传入。int updateById(T entity);
4、Select
// 根据 ID 查询T selectById(Serializable id);// 根据 entity 条件,查询一条记录T selectOne(@Param(Constants.WRAPPER) Wrapper queryWrapper);// 查询(根据ID 批量查询,与上述删除类似)List selectBatchIds(@Param(Constants.COLLECTION) Collection