網(wǎng)站首頁 編程語言 正文
01 Mybatis-plus的CRUD
-
Mybatis-plus實(shí)現(xiàn)了單表的增刪改查
-
create 添加數(shù)據(jù) read讀取數(shù)據(jù) update 修改數(shù)據(jù) delete刪除數(shù)據(jù)
02 簡(jiǎn)單的mybatis-plus方法
-
測(cè)試類
public class Category { @TableId private Long categoryId; private String categoryName; private String categoryPicture1; private String categoryPicture2; }
1.增加insert
// 向數(shù)據(jù)庫插入一條記錄
Category category=new Category();
category.setCategoryName("電腦");
Long num=new Long(100);
category.setCategoryId(num);
boolean add=iCategoryService.save(category);
2.刪除delete
// 根據(jù) ID 刪除
Category category=new Category();
category.setCategoryName("機(jī)器人");
Long num=new Long(100);
category.setCategoryId(num);
boolean delete=iCategoryService.removeById(category);
//或者直接傳主鍵也是可以刪除的
boolean delete=iCategoryService.removeById(new Long(100));
3.修改update
//根據(jù)ID修改
Category category=new Category();
category.setCategoryName("機(jī)器人");
Long num=new Long(100);
category.setCategoryId(num);
boolean update=iCategoryService.updateById(category);
4.查找select
// 查找對(duì)應(yīng)數(shù)據(jù)庫所有數(shù)據(jù)
List<Category> categories=iCategoryService.list();
// 根據(jù)表主鍵查詢一條數(shù)據(jù)
Category category=iCategoryService.getById(new Long(100));
// 根據(jù)數(shù)據(jù)庫批量查詢
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
- 上一篇:沒有了
- 下一篇:沒有了
相關(guān)推薦
- 2022-01-03 yarn版本過低導(dǎo)致的報(bào)錯(cuò)
- 2022-04-26 Python中的3D繪圖命令總結(jié)_python
- 2023-10-11 小程序|頁面?zhèn)鲄⒌娜N方式
- 2022-09-20 C#使用winform實(shí)現(xiàn)進(jìn)度條效果_C#教程
- 2022-09-22 YOLO v5模型的yaml文件參數(shù)理解
- 2023-01-20 解決Building?wheel?for?wrapt?(setup.py)?...?error的問題
- 2022-08-02 Redis實(shí)現(xiàn)登錄注冊(cè)的示例代碼_Redis
- 2022-10-29 css transform導(dǎo)致字體像素模糊的問題解決辦法
- 欄目分類
-
- 最近更新
-
- window11 系統(tǒng)安裝 yarn
- 超詳細(xì)win安裝深度學(xué)習(xí)環(huán)境2025年最新版(
- Linux 中運(yùn)行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲(chǔ)小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎(chǔ)操作-- 運(yùn)算符,流程控制 Flo
- 1. Int 和Integer 的區(qū)別,Jav
- spring @retryable不生效的一種
- Spring Security之認(rèn)證信息的處理
- Spring Security之認(rèn)證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權(quán)
- redisson分布式鎖中waittime的設(shè)
- maven:解決release錯(cuò)誤:Artif
- restTemplate使用總結(jié)
- Spring Security之安全異常處理
- MybatisPlus優(yōu)雅實(shí)現(xiàn)加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務(wù)發(fā)現(xiàn)-Nac
- Spring Security之基于HttpR
- Redis 底層數(shù)據(jù)結(jié)構(gòu)-簡(jiǎn)單動(dòng)態(tài)字符串(SD
- arthas操作spring被代理目標(biāo)對(duì)象命令
- Spring中的單例模式應(yīng)用詳解
- 聊聊消息隊(duì)列,發(fā)送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠(yuǎn)程分支