網站首頁 編程語言 正文
01 Mybatis-plus的CRUD
-
Mybatis-plus實現了單表的增刪改查
-
create 添加數據 read讀取數據 update 修改數據 delete刪除數據
02 簡單的mybatis-plus方法
-
測試類
public class Category { @TableId private Long categoryId; private String categoryName; private String categoryPicture1; private String categoryPicture2; }
1.增加insert
// 向數據庫插入一條記錄
Category category=new Category();
category.setCategoryName("電腦");
Long num=new Long(100);
category.setCategoryId(num);
boolean add=iCategoryService.save(category);
2.刪除delete
// 根據 ID 刪除
Category category=new Category();
category.setCategoryName("機器人");
Long num=new Long(100);
category.setCategoryId(num);
boolean delete=iCategoryService.removeById(category);
//或者直接傳主鍵也是可以刪除的
boolean delete=iCategoryService.removeById(new Long(100));
3.修改update
//根據ID修改
Category category=new Category();
category.setCategoryName("機器人");
Long num=new Long(100);
category.setCategoryId(num);
boolean update=iCategoryService.updateById(category);
4.查找select
// 查找對應數據庫所有數據
List<Category> categories=iCategoryService.list();
// 根據表主鍵查詢一條數據
Category category=iCategoryService.getById(new Long(100));
// 根據數據庫批量查詢
LinkedList<Long> list = new LinkedList<>();
list.add(new Long(1));
list.add(new Long(2));
list.add(new Long(3));
List<Category> categoryList=iCategoryService.listByIds(list);
原文鏈接:https://blog.csdn.net/2302_77182979/article/details/134471698
- 上一篇:沒有了
- 下一篇:沒有了
相關推薦
- 2022-07-09 Python?對數字的千分位處理方式_python
- 2022-06-01 python中parser.add_argument()用法實例(命令行選項、參數和子命令解析器)_
- 2022-04-16 詳解C語言通過遞歸與非遞歸實現蛇形矩陣_C 語言
- 2023-08-28 Antd的日期選擇器中文化配置
- 2022-04-30 Winform項目中TextBox控件DataBindings屬性_C#教程
- 2022-10-17 Django?logging日志模塊實例詳解(日志記錄模板配置)_python
- 2022-05-04 python?與c++相互調用實現_python
- 2022-10-02 C#利用FileSystemWatcher實時監控文件的增加,修改,重命名和刪除_C#教程
- 欄目分類
-
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支