網站首頁 編程語言 正文
描述: 給定一個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-08-18 C#開發Windows?UWP系列之對話框MessageDialog和ContentDialog_C
- 2022-06-24 Python集合之set和frozenset的使用詳解_python
- 2022-09-30 Centos7?Shell編程之正則表達式、文本處理工具詳解_正則表達式
- 2022-07-03 python使用pandas讀xlsx文件的實現_python
- 2023-03-16 淺析Kotlin使用infix函數構建可讀語法流程講解_Android
- 2022-07-21 Pandas常用數據結構
- 2022-07-28 XML基本概念XPath、XSLT與XQuery函數介紹_XML/RSS
- 2022-12-23 淺析Go語言中Channel的各種用法_Golang
- 欄目分類
-
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支