Mybatis 返回List 报The error occurred while handling results

时间:2025-02-13 08:58:53

1.首先要明白返回list 时 ,xml 中 resultType 的配置

1. 返回的为 List<String> 类型, resultType= ""
2. 返回的为 List<Vo>类型,   resultType= ""
2. 返回为实体List<VO>时,如果实体的属性值都为null,也会报这个错,本人刚好遇到。
<select  resultType= "">
        SELECT DISTINCT  as faId, as faName
        FROM a
        WHERE  is not null
        and  is not null
        <if test="vueIds != null and () > 0">
            and  IN
            <foreach collection="vueIds" item="vueId" open="(" separator="," close=")">
                #{vueId}
            </foreach>
        </if>

    </select>
 

这个是修改后的sql, sql中没有 and is not null , 导致 筛选的2个字段都为null, 就会返回报错