MyBatis-Plus BaseMapper和IService使用手冊


Mybatis-plus 文檔

注釋 mapper extends BaseMapper service extends IService 注釋
DDML 進一步封裝:采用 get 查詢單行, remove 刪除, list 查詢集合, page 分頁
int insert(T entity); boolean save(T entity); 選擇字段,策略插入
boolean saveBatch(Collection entityList); 批量插入
boolean saveOrUpdateBatch(Collection entityList);
int deleteById(Serializable id); boolean removeById(Serializable id);
根據 entity 條件刪除 int delete(Wrapper wrapper); boolean remove(Wrapper queryWrapper); 無對應記錄也返回true
columnMap 刪除條件 int deleteByMap(Map<String, Object> columnMap); boolean removeByMap(Map<String, Object> columnMap); columnMap 表字段 map 對象
int updateById(T entity); boolean updateById(T entity);
boolean saveOrUpdate(T entity);
T selectById(Serializable id); T getById(Serializable id);
columnMap查詢條件 List selectByMap(Map<String, Object> columnMap); Collection listByMap(Map<String, Object> columnMap);
如果邏輯非唯一需要
wrapper.last("limit 1") 設置唯一性
T selectOne(Wrapper queryWrapper); T getOne(Wrapper queryWrapper); 有多個取一個
Integer selectCount(Wrapper queryWrapper); int count(Wrapper queryWrapper);
List selectList(Wrapper queryWrapper); List list(Wrapper queryWrapper);
只能查詢一個字段
List<Object> cols;
List<String> l = (List)cols;
List<Object> selectObjs(Wrapper queryWrapper); List<Object> listObjs(Wrapper queryWrapper); 根據 Wrapper 條件,查詢全部記錄
IPage selectPage(IPage page, Wrapper queryWrapper); IPage page(IPage page, Wrapper queryWrapper);


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM