当前位置:网站首页>使用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
都看到这里了,下面的内容你懂得,让我们共同进步!
边栏推荐
- What are the consequences of opening an account with Huatai Securities? How to open an account is the safest
- Who is the main body of the waiting insurance record? Record in the local network security, right?
- Configuration file encryption (simple use of jasypt)
- 2022 Chinese cook (Advanced) test questions and online simulation test
- 2022 recurrent training question bank and online simulation examination for safety inspection of metal and nonmetal mines (underground mines)
- Recommended practice sharing of Zhilian recruitment based on Nebula graph
- 从小小线虫谈起——溯源神经系统进化,开启生命模拟
- 腾讯再遭大股东Prosus减持:后者还从京东套现37亿美元
- Jingyuan's safe sprint to the Growth Enterprise Market: it plans to raise 400million yuan for investment and Yunyou software is the shareholder
- Based on asp Net based document retrieval system
猜你喜欢

Thread life cycle and its methods

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

Tencent was underweight again by prosus, the major shareholder: the latter also cashed out $3.7 billion from JD

PC Museum - familiar and strange ignorant age

CVPR disputes again: IBM's Chinese draft papers were accused of copying idea, who won the second place in the competition

ArrayList源码解析

Dry goods | how to calculate the KPI of scientific researchers, and what are the h index and G index

Euler equation: a truly perfect formula in the history of mathematics!

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

外贸邮件推广怎么统计维度
随机推荐
猫狗队列
How to design data visualization platform
IonQ联合GE Research证实:量子计算在风险聚合上有巨大潜力
Rslo: self supervised lidar odometer (real time + high precision, icra2022)
开闭原则
证券公司和银行哪个更安全 怎么办理开户最安全
[Zhongyi Xinsheng] 5 SPI interface test TF Card
美因基因港交所上市:市值43亿港元 IPO被市场忽略
2022 recurrent training question bank and online simulation examination for safety inspection of metal and nonmetal mines (underground mines)
Is it safe to open an account on the flush
sort
荐书丨《大脑通信员》:如果爱情只是化学反应,那还能相信爱情吗?
Ruijie switch configuration SSH password login command [easy to understand]
[binary tree] the minimum string starting from the leaf node
Jingyuan's safe sprint to the Growth Enterprise Market: it plans to raise 400million yuan for investment and Yunyou software is the shareholder
ArrayList源码解析
Foreign trade SEO Webmaster Tools
Clipping of raster vector data
Votre Code parle? (1)
10 key points to effectively improve performance interview