当前位置:网站首页>使用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
都看到这里了,下面的内容你懂得,让我们共同进步!
边栏推荐
- 力扣解法汇总522-最长特殊序列 II
- Differences between ram ROM flash
- Kwai investment e-commerce service provider Yixin optimization
- 一个bug肝一周...忍不住提了issue
- 腾讯再遭大股东Prosus减持:后者还从京东套现37亿美元
- [binary tree] the minimum string starting from the leaf node
- 基于asp.net的文献检索系统
- 量子前沿英雄谱|“光量子探险家”McMahon:将任何物理系统变成神经网络
- 2022金属非金属矿山安全检查(地下矿山)复训题库及在线模拟考试
- What does VPS do? What are the famous brands? What is the difference with ECS?
猜你喜欢

如何设计数据可视化平台

线程终止的 4 种方式

Four visualization tools are recommended to solve 99% of large screen visualization projects!

Work study management system based on ASP

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

Rslo: self supervised lidar odometer (real time + high precision, icra2022)

物联网低代码平台常用《组件介绍》

Talking from the little nematode -- tracing the evolution of nervous system and starting life simulation

Only four breakthrough Lenovo smart Summer Palace in mainland China won the "IDC Asia Pacific Smart City Award in 2022"

What is the progress of China open source with 7.55 million developers?
随机推荐
开闭原则
接雨水系列问题
竞远安全冲刺创业板:拟募资4亿 启元投资与云游软件是股东
Jingyuan's safe sprint to the Growth Enterprise Market: it plans to raise 400million yuan for investment and Yunyou software is the shareholder
优巨新材冲刺深交所:拟募资6.5亿 年营收3.33亿
Clipping of raster vector data
Unable to create process using 'd:\program file
MySQL从库Error:“You cannot ‘Alter‘ a log table...“
i++ , ++i
【中移芯昇】5. spi接口测试tf卡
js 判断字符串为空或者不为空
猫狗队列
Ruijie switch configuration SSH password login command [easy to understand]
单一职责原则
只出现一次的数字(水了个简单题)
从小小线虫谈起——溯源神经系统进化,开启生命模拟
Who is the main body of the waiting insurance record? Record in the local network security, right?
机器人的运动范围(DFS)
名创优品通过上市聆讯:寻求双重主要上市 年营收91亿
ArrayList源码解析