当前位置:网站首页>使用LamdbaUpdateWrapper的setSql作用及风险
使用LamdbaUpdateWrapper的setSql作用及风险
2022-06-28 14:27:00 【华为云】
title: 使用LamdbaUpdateWrapper的setSql作用及风险
date: 2022-04-12 18:10:34
tags: java
问题引入
先思考下:我们要对数据库里面的某条数据进行更新,并且想要在某个字段原先的基础上修改,我们怎么办?
正常的情况下,我们需要先查出来再更新,可就是想直接更新,那就需要去Mapper中写sql,就为了一个字段感觉费劲,在这种情况下使用LamdbaUpdateWrapper的setSql()方法即可。
//把num字段加5LambdaUpdateWrapper<User> updateWrapper = Wrappers.<User>lambdaUpdate() .eq(User::getId, userId) .setSql("count = count + 5");userService.update(updateWrapper);BUT,这样就会存在可能有风险,主要还是为了测试mybatis-plus,是否进行的防范,经过测试,并没有。
比如就使用最常见的 sleep(),把这部分加到sql段中 + sleep(5)
LambdaUpdateWrapper<User> updateWrapper = Wrappers.<User>lambdaUpdate() .eq(User::getId, userId) .setSql("count = count + 5 + sleep(5)");
不过话说回来,这也就是开发人员能接触到的,只是证明mybatis-plus并没有对setSql()进行过滤,是采取直接拼上去的方式。
每日单词

以上就是使用LamdbaUpdateWrapper的setSql作用及风险的全部内容
版权声明:
原创博主:牛哄哄的柯南
个人博客链接:https://www.keafmd.top/
看完如果对你有帮助,感谢点击下面的==一键三连==支持!
[哈哈][抱拳]

加油!
共同努力!
Keafmd
都看到这里了,下面的内容你懂得,让我们共同进步!
边栏推荐
- Practice of constructing ten billion relationship knowledge map based on Nebula graph
- Analysis and processing of GPS data format [easy to understand]
- A bug liver a week I can't help mentioning issue
- Double buffer drawing
- 运行近20年,基于Win 98的火星探测器软件迎来首次升级
- 只出现一次的数字(水了个简单题)
- 2022 welder (technician) examination question bank simulated examination platform operation
- flutter 系列之:flutter 中的 offstage
- sort
- 同花顺上开户是安全的吗
猜你喜欢

What is the progress of China open source with 7.55 million developers?

Kwai investment e-commerce service provider Yixin optimization

Mingchuangyou products passed the listing hearing: seeking dual main listing with an annual revenue of 9.1 billion

中国内地仅四家突围 联想智慧颐和园荣获 “2022年IDC亚太区智慧城市大奖”

Jingyuan's safe sprint to the Growth Enterprise Market: it plans to raise 400million yuan for investment and Yunyou software is the shareholder

竞远安全冲刺创业板:拟募资4亿 启元投资与云游软件是股东

Recommended practice sharing of Zhilian recruitment based on Nebula graph

叮!Techo Day 腾讯技术开放日如约而至!

IonQ联合GE Research证实:量子计算在风险聚合上有巨大潜力

坐拥755万开发者的中国开源,进度几何?
随机推荐
MySQL slave error: "you cannot 'alter' a log table“
Angers medical sprint scientific innovation board: annual revenue of RMB 300million and proposed fund raising of RMB 770million
哪个证券公司最大最安全 怎么办理开户最安全
外贸SEO 站长工具
木兰开放作品许可证1.0面向社会公开征求意见
Foreign trade SEO Webmaster Tools
推荐四款可视化工具,解决 99% 的可视化大屏项目!
Npoi export excel and download to client
GPS数据格式的分析与处理[通俗易懂]
线程终止的 4 种方式
2022中式烹调师(高级)试题及在线模拟考试
Numbers that only appear once
Work study management system based on ASP
A bug liver a week I can't help mentioning issue
Nature | mapping the interaction map of plant foliar flora to establish genotype phenotype relationship
【二叉树】在二叉树中分配硬币
What are the consequences of opening an account with Huatai Securities? How to open an account is the safest
Why can't Bert completely kill the BM25??
Source code analysis of ArrayList
G: maximum flow problem