热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

MyBatisPlusMapper的CRUD接口

Insert插入一条记录intinsert(Tentity);类型参数名描述Tentity实体对象Delete根据entity条件,删除记录intdelet

Insert

// 插入一条记录
int insert(T entity);

类型参数名描述
Tentity实体对象

Delete

// 根据 entity 条件,删除记录
int delete(&#64;Param(Constants.WRAPPER) Wrapper<T> wrapper);
// 删除&#xff08;根据ID 批量删除&#xff09;
int deleteBatchIds(&#64;Param(Constants.COLLECTION) Collection<? extends Serializable> idList);
// 根据 ID 删除
int deleteById(Serializable id);
// 根据 columnMap 条件&#xff0c;删除记录
int deleteByMap(&#64;Param(Constants.COLUMN_MAP) Map<String, Object> columnMap);

类型参数名描述
Wrapperwrapper实体对象封装操作类&#xff08;可以为 null&#xff09;
CollectionidList主键ID列表(不能为 null 以及 empty)
Serializableid主键ID
MapcolumnMap表字段 map 对象

Update

// 根据 whereEntity 条件&#xff0c;更新记录
int update(&#64;Param(Constants.ENTITY) T entity, &#64;Param(Constants.WRAPPER) Wrapper<T> updateWrapper);
// 根据 ID 修改
int updateById(&#64;Param(Constants.ENTITY) T entity);

类型参数名描述
Tentity实体对象 (set 条件值,可为 null)
WrapperupdateWrapper实体对象封装操作类&#xff08;可以为 null,里面的 entity 用于生成 where 语句&#xff09;

Select

T selectById(Serializable id);
// 根据 entity 条件&#xff0c;查询一条记录
T selectOne(&#64;Param(Constants.WRAPPER) Wrapper<T> queryWrapper);// 查询&#xff08;根据ID 批量查询&#xff09;
List<T> selectBatchIds(&#64;Param(Constants.COLLECTION) Collection<? extends Serializable> idList);
// 根据 entity 条件&#xff0c;查询全部记录
List<T> selectList(&#64;Param(Constants.WRAPPER) Wrapper<T> queryWrapper);
// 查询&#xff08;根据 columnMap 条件&#xff09;
List<T> selectByMap(&#64;Param(Constants.COLUMN_MAP) Map<String, Object> columnMap);
// 根据 Wrapper 条件&#xff0c;查询全部记录
List<Map<String, Object>> selectMaps(&#64;Param(Constants.WRAPPER) Wrapper<T> queryWrapper);
// 根据 Wrapper 条件&#xff0c;查询全部记录。注意&#xff1a; 只返回第一个字段的值
List<Object> selectObjs(&#64;Param(Constants.WRAPPER) Wrapper<T> queryWrapper);// 根据 entity 条件&#xff0c;查询全部记录&#xff08;并翻页&#xff09;
IPage<T> selectPage(IPage<T> page, &#64;Param(Constants.WRAPPER) Wrapper<T> queryWrapper);
// 根据 Wrapper 条件&#xff0c;查询全部记录&#xff08;并翻页&#xff09;
IPage<Map<String, Object>> selectMapsPage(IPage<T> page, &#64;Param(Constants.WRAPPER) Wrapper<T> queryWrapper);
// 根据 Wrapper 条件&#xff0c;查询总记录数
Integer selectCount(&#64;Param(Constants.WRAPPER) Wrapper<T> queryWrapper);

类型参数名描述
Serializableid主键ID
WrapperqueryWrapper实体对象封装操作类&#xff08;可以为 null&#xff09;
CollectionidList主键ID列表(不能为 null 以及 empty)
MapcolumnMap表字段 map 对象
IPagepage分页查询条件&#xff08;可以为 RowBounds.DEFAULT&#xff09;

推荐阅读
author-avatar
风中凌乱2602938623
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有