当前位置:网站首页>使用LamdbaUpdateWrapper的setSql作用及风险
使用LamdbaUpdateWrapper的setSql作用及风险
2022-04-21 09:21:00 【牛哄哄的柯南】
title: 使用LamdbaUpdateWrapper的setSql作用及风险
date: 2022-04-12 18:10:34
tags: java
问题引入
先思考下:我们要对数据库里面的某条数据进行更新,并且想要在某个字段原先的基础上修改,我们怎么办?
正常的情况下,我们需要先查出来再更新,可就是想直接更新,那就需要去Mapper中写sql,就为了一个字段感觉费劲,在这种情况下使用LamdbaUpdateWrapper的setSql()方法即可。
//把num字段加5
LambdaUpdateWrapper<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://keafmd.blog.csdn.net/
个人博客链接:https://www.keafmd.top/
看完如果对你有帮助,感谢点击下面的一键三连支持!
[哈哈][抱拳]


加油!
共同努力!
Keafmd
都看到这里了,下面的内容你懂得,让我们共同进步!
版权声明
本文为[牛哄哄的柯南]所创,转载请带上原文链接,感谢
https://keafmd.blog.csdn.net/article/details/124249977
边栏推荐
- 头大毕设论文模板适配指南
- 1151: large integer addition
- Handler asynchronous message passing mechanism (2) create handler in sub thread
- Redisson简介和整合
- Pipy mqtt agent (III) logging
- kotlin 协程 lanch 详解
- 1164: 字符串加密
- [appium] use the simulator to realize the business functions of Youdao cloud app - add, search, modify and delete
- About shardingsphere
- C language counting and sorting
猜你喜欢

Dark blue - Visual slam - Section 6 exercise

深蓝-视觉slam-第六节习题

Meizu, once expected to challenge apple, now lives by providing accessories for Apple users

Based on ASP Net online flower shopping management

Pys1: Overview

CC10000.CloudJenkins—————————————

Detailed explanation of native and H5 mixed development

PageRank case Airport

二叉树知识

Geek challenge 2019 upload 1
随机推荐
1163: affinity string (string)
1150: 数数多少个整数
CC00019. CloudJenkins—————————————
Handler异步消息传递机制(二)在子线程中创建Handler
Pyinstaller package exe (detailed tutorial)
1166: 实数取整(指针专题)
全网最全谷粒商城笔记_02、简介项目整体效果展示(2022-04-02)
Zabbix 5.4 Server安装
1146: 吃糖果
【ACM】131. Split palindrome string
1164: string encryption
Opencv -- separate color channel, image contrast, brightness adjustment, discrete Fourier transform (10)
Simulation implementation vector
Error in idea connection to sqlserver
数据库有张表,其中一个字段存的是json数据,我需要在这张表有更新的时候,解析这个字符串,然后把解析的json数据更新到另外一个表,有什么好的建议?
A summary of school training
Implementation of pure student information linked list system in C Have you learned
BUUCTF[极客大挑战 2019]Havefun
Buuctf [geek challenge 2019] easysql
1161: 字符串长度(指针专题)