当前位置:网站首页>Setsql function and risk of using lamdbaupdatewrapper
Setsql function and risk of using lamdbaupdatewrapper
2022-06-28 14:44:00 【Hua Weiyun】
title: Use LamdbaUpdateWrapper Of setSql Role and risk
date: 2022-04-12 18:10:34
tags: java
Problem introduction
Think about it first : We need to update a piece of data in the database , And want to modify a field based on the original , What shall we do ?
Under normal circumstances , We need to find out before updating , But I just want to update it directly , Then you need to Mapper Write in sql, It's hard for a field , Use in this case LamdbaUpdateWrapper Of setSql() The method can .
// hold num Field plus 5LambdaUpdateWrapper<User> updateWrapper = Wrappers.<User>lambdaUpdate() .eq(User::getId, userId) .setSql("count = count + 5");userService.update(updateWrapper);BUT, In this way, there may be risks , Mainly for testing mybatis-plus, Whether to take preventive measures , After testing , did not .
For example, use the most common sleep(), Add this part to sql In the paragraph + sleep(5)
LambdaUpdateWrapper<User> updateWrapper = Wrappers.<User>lambdaUpdate() .eq(User::getId, userId) .setSql("count = count + 5 + sleep(5)");
But then again , This is what developers can access , Just to prove mybatis-plus It did not setSql() To filter , It's a direct way to spell it up .
Daily words

The above is the use of LamdbaUpdateWrapper Of setSql Full contents of functions and risks
Copyright notice :
Original Blogger : Cowherd Conan
Personal blog links :https://www.keafmd.top/
If it helps you , Thank you for clicking on == One key, three links == Support !
[ ha-ha ][ Huai Quan ]

come on. !
Joint efforts !
Keafmd
You can see it here , You know the following , Let's make progress together !
边栏推荐
猜你喜欢

Q-tester 3.2: applicable to development, production and after-sales diagnostic test software

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

Mulan open work license 1.0 open to the public for comments

基于asp.net的文献检索系统

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

sort

Maingene listed on the Hong Kong Stock Exchange: IPO with a market value of HK $4.3 billion was ignored by the market

PMP真的有用吗?

Softing epGate PB系列网关-可将PROFIBUS总线集成到EtherNet/IP网络

【mysql学习笔记23】索引优化
随机推荐
2022 welder (technician) examination question bank simulated examination platform operation
Le patron a donné trois ordres: discret, discret, discret
老板嘱咐了三遍:低调、低调、低调
法兰克福地区目前支持sql了吗?
Research and Simulation of chaotic digital image encryption technology based on MATLAB
Force deduction solution summary 522- longest special sequence II
Performance comparison of deep learning models on cat and dog image data sets
运行近20年,基于Win 98的火星探测器软件迎来首次升级
外贸邮件推广怎么统计维度
Rails advanced -- framework theory cognition and construction scheme construction (I)
有效提高绩效面谈的10个关键点
Seata数据库中出现以下问题要怎么解决啊?
Kwai investment e-commerce service provider Yixin optimization
Angers medical sprint scientific innovation board: annual revenue of RMB 300million and proposed fund raising of RMB 770million
seata-server 1.5.0 如何支持mysql8.0?
Practice of constructing ten billion relationship knowledge map based on Nebula graph
Leetcode(88)——合并两个有序数组
Which securities company is the largest and safest? How to open an account is the safest
Maingene listed on the Hong Kong Stock Exchange: IPO with a market value of HK $4.3 billion was ignored by the market
智联招聘基于 Nebula Graph 的推荐实践分享