当前位置: 首页 > news >正文

Mybatis中sql数组为空判断

一、Mybatis xml中的sql通过if语句判定是否为空
<if test="arrays != null">
</if>

上述示例只能判断arrays数组不为null,那如果是个空数组呢

二、Mybatis xml中的sql通过if语句判定数组非空数组

<if test="arrays != null and arrays.length > 0">
</if>

如果是按照上述写法,将会报如下已异常:

nested exception is org.apache.ibatis.builder.BuilderException: Error evaluating expression 'arrays != null and arrays.length > 0'. Cause: org.apache.ibatis.ognl.NoSuchPropertyException: java.util.ArrayList.length

正确写法如下:

<if test="arrays != null and arrays.size() > 0">
</if>

开源SDK:https://github.com/mingyang66/spring-parent


http://www.mrgr.cn/news/29606.html

相关文章:

  • 智能优化算法-遗传算法(GA)(附源码)
  • MySQL5.7主从复制搭建-gtid方式
  • 音视频入门基础:AAC专题(8)——FFmpeg源码中计算AAC裸流AVStream的time_base的实现
  • OpenCV-直方图
  • 数据处理与统计分析篇-day03-Numpy环境搭建
  • 在Windows操作系统中,如何再命令提示符(cmd)中快速打开自启动文件夹?
  • TCP/IP Socket用于测试免费使用的服务器端
  • C++中类的创建和声明
  • Vmware虚拟机无法打开内核设备“\\.\Global\vmx86“的解决方法
  • Gitlab升级14.0.12-->14.3.6遇到的gitlab-ctl reconfigure错误
  • MySQL聚合统计和内置函数
  • JS基础:数组for循环年龄案例
  • 「已解决」KeyError: ‘getpwuid(): uid not found: 1004‘
  • WildFly概述
  • MYSQL常用基本操作总结
  • Selenium
  • iOS六大设计原则设计模式
  • 【高级数据结构】树状数组
  • 基于Redis实现幂等判断
  • MongoDB