行业知识
BaseMapper接口的使用
2026-12-06 22:16:00
来源:互联网转载
Java知识点总结:想看的可以从这里进入
目录
- 3、相关方法
- 3.1、BaseMapper接口
- 3.1.1、新增
- 3.1.2、删除
- 3.1.3、修改
- 3.1.4、查询
3、相关方法
3.1、BaseMapper接口
MyBatis-Plus中的基本CRUD在内置的 BaseMapper 中都已得到了实现,我们可以直接使用,这样大大的简化了开发效率。
/** * Mapper 继承该接口后,无需编写 mapper.xml 文件,即可获得CRUD功能 */public interface BaseMapper extends Mapper { //插入一条记录 int insert(T entity); //根据 ID 删除 int deleteById(Serializable id); //根据实体(ID)删除 int deleteById(T entity); //根据 columnMap 条件,删除记录 int deleteByMap(@Param(Constants.COLUMN_MAP) Map columnMap); // 删除记录,条件生成器根据entity生成where后的条件 int delete(@Param(Constants.WRAPPER) Wrapper queryWrapper); //删除(根据ID或实体 批量删除) int deleteBatchIds(@Param(Constants.COLL) Collection idList); // 根据 ID 修改 int updateById(@Param(Constants.ENTITY) T entity); // 根据 whereEntity 条件,更新记录 int update(@Param(Constants.ENTITY) T entity, @Param(Constants.WRAPPER) Wrapper updateWrapper); //根据 ID 查询 T selectById(Serializable id); //查询(根据ID 批量查询) List selectBatchIds(@Param(Constants.COLL) Collection
上一篇:云服务器帧率怎么看?
下一篇:电脑辅助手绘教程