網(wǎng)站首頁 編程語言 正文
描述: 給定一個id列表,更新對應列表中動物的年齡,使得年齡都較少一歲。
要求:使用條件構造器構造條件。
?mapper:
void updateAnimalAge(@Param(Constants.WRAPPER) Wrapper<Animal> wrapper, @Param("age") int reducedAge);
xml:
<update id="updateAnimalAge">
update `animal` set `age` = `age` - #{age}
<where>
${ew.sqlSegment}
</where>
</update>
service:
@org.junit.Test
public void test() {
ArrayList<String> strings = Lists.newArrayList();
strings.add("1775e2db7fb5e0d9b8e98d4137f58b91");
strings.add("23d210703b33bd67b901e147f874a831");
int reducedAge = 1;
LambdaQueryWrapper<Animal> wrapper = new QueryWrapper<Animal>().lambda();
wrapper.in(Animal::getId,strings);
this.animalMapper.updateAnimalAge(wrapper,reducedAge);
//
// if (successful.size() > 0) {
// System.out.println("success!!");
// } else {
// System.out.println("failed!!");
// }
}
sql:
JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@3c50ad4b] will not be managed by Spring
==> Preparing: update `animal` set `age` = `age` - ? WHERE (id IN (?,?))
==> Parameters: 1(Integer), 1775e2db7fb5e0d9b8e98d4137f58b91(String), 23d210703b33bd67b901e147f874a831(String)
<== Updates: 2
原文鏈接:https://blog.csdn.net/m0_59259076/article/details/133430887
- 上一篇:沒有了
- 下一篇:沒有了
相關推薦
- 2022-06-28 C++詳解多線程中的線程同步與互斥量_C 語言
- 2024-03-20 解決npm install遇到的問題:Error while executing:
- 2022-10-24 C語言進程程序替換的實現(xiàn)詳解_C 語言
- 2022-04-25 Entity?Framework?Core中執(zhí)行SQL語句和存儲過程的方法介紹_實用技巧
- 2022-04-27 Jquery實現(xiàn)移動端控制DIV拖拽_jquery
- 2023-03-29 基于WPF實現(xiàn)多選下拉控件的示例代碼_C#教程
- 2022-07-02 如何對numpy?矩陣進行通道間求均值_python
- 2023-04-11 一文帶你搞懂useCallback的使用方法_React
- 欄目分類
-
- 最近更新
-
- window11 系統(tǒng)安裝 yarn
- 超詳細win安裝深度學習環(huán)境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區(qū)別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優(yōu)雅實現(xiàn)加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發(fā)現(xiàn)-Nac
- Spring Security之基于HttpR
- Redis 底層數(shù)據(jù)結構-簡單動態(tài)字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發(fā)送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支