java~springboot~ibatis数组in查询的实现方法
作者:mrr 时间:2023-03-31 21:31:13
在ibatis的xml文件里,我们去写sql语句,对应mapper类的方法,这些sql语句与控制台上没什么两样,但在有些功能上需要注意,如where in这种从数组里查询符合条件的集合里,需要在xml里进行特别的处理。
<update id="batchUpdate" parameterType="map">
update customer_info set status=#{status},appoint_time=#{appointTime} where
customer_id in
<foreach collection="customerIdArr" item="customerId"
index="index" open="(" close=")" separator=",">
#{customerId}
</foreach>
</update>
我们可以看到,在xml里进行了foreach的遍历,而外部参数是一个集合或者数组的对象,我们在xml对它进行遍历,还是比较方便的。
技巧:在xml里,parameterType是输入参数类型,你可以使用map对象来代替;而resultType是返回类型,如果你没有定义DTO也可以使用map代替,虽然map可以让我们的代码变简洁,当然也有缺陷,就是会写很多弱类型的属性名。
总结
以上所述是小编给大家介绍的java~springboot~ibatis数组in查询的实现方法网站的支持!
标签:spring,boot,java,in,查询
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Android 优化之卡顿优化的实现
2022-03-03 21:34:25
基于Java8 Stream API实现数据抽取收集
2021-10-01 03:13:03
C#中float的取值范围和精度分析
2023-05-19 01:03:21
![](https://img.aspxhome.com/file/2023/1/85731_0s.png)
Java线程池submit阻塞获取结果的实现原理详解
2021-08-29 03:55:45
![](https://img.aspxhome.com/file/2023/7/64797_0s.png)
使用Mybatis-Plus时的SqlSessionFactory问题及处理
2022-01-30 07:40:04
Android上传文件到服务器的方法
2021-10-05 21:21:57
![](https://img.aspxhome.com/file/2023/5/101835_0s.jpg)
Java杂谈之重复代码是什么
2022-06-08 15:07:24
C#设计模式之Singleton模式
2022-03-28 09:01:31
![](https://img.aspxhome.com/file/2023/5/86995_0s.png)
C++实现简易反弹小球游戏的示例代码
2023-06-15 08:18:50
![](https://img.aspxhome.com/file/2023/5/112305_0s.jpg)
Java装饰者模式的示例详解
2022-03-30 07:26:22
![](https://img.aspxhome.com/file/2023/6/114046_0s.jpg)
Android开发之使用ExifInterface获取拍照后的图片属性
2021-05-29 23:36:36
SpringBoot+微信小程序实现文件上传与下载功能详解
2023-01-17 15:56:39
![](https://img.aspxhome.com/file/2023/2/97782_0s.jpg)
Java实现求解一元n次多项式的方法示例
2022-08-24 09:03:33
![](https://img.aspxhome.com/file/2023/0/64790_0s.png)
Android编程实现图片放大缩小功能ZoomControls控件用法实例
2022-07-16 22:01:11
Java简单计时的实现案例(可以用来限时循环)
2023-02-01 21:39:19
Android开发新手常见的10个误区
2021-07-30 02:14:10
基于C#实现屏幕取色器
2023-02-16 04:17:53
![](https://img.aspxhome.com/file/2023/2/122642_0s.png)
浅谈几种常见语言的命名空间(Namespace)
2022-11-13 12:17:42
Hibernate hql查询代码实例
2021-07-24 18:03:33
SpringBoot响应处理之以Json数据返回的实现方法
2023-12-21 12:21:47
![](https://img.aspxhome.com/file/2023/8/61638_0s.png)