今天查看日志的时候发现多次出现如下的异常,查阅了资料后发现IN
语句中写的表达式的最大数量不能超过1000。
解决方法: 1. 拆分IN
里面的条件,将表达式的数量控制在1000以内,然后通过OR
语句连接。
2.作为子查询。
我使用了第二种方法:
<if test="createBy != null and createBy.name != null and createBy.name != ''"> AND a.create_by in (select u.id as "createBy.id" FROM sys_user u where u.name LIKE <if test="dbName == 'oracle'">'%'||#{createBy.name}||'%'</if> <if test="dbName == 'mssql'">'%'+#{createBy.name}+'%'</if> <if test="dbName == 'mysql'">concat('%',#{createBy.name},'%')</if> ) </if>
第一种方法有时间再试