mytbatis mapper.xml报错:java.lang.UnsupportedOperationException] with root cause

Posted 蜜桃婷婷酱

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mytbatis mapper.xml报错:java.lang.UnsupportedOperationException] with root cause相关的知识,希望对你有一定的参考价值。

Cause: java.lang.UnsupportedOperationException] with root cause java.lang.UnsupportedOperationException: null

mapper层接口

   List selectRolePredict(@Param("organId") String organId,@Param("businessId") String businessId);

mybatis.xml sql结构

 <select id="selectRolePredict" resultType="list">
            select  DISTINCT  next_approval_role from business_node_approval_role
            <where>
                organ_id=#organId and business_id=#businessId and !isnull(next_approval_role)
            </where>
    </select>

解决方法:把resultType=“java.util.List” 改为String

原因:
resultType返回的是集合中的元素类型,而不是集合本身

 <select id="selectRolePredict" resultType="string">
            select  DISTINCT  next_approval_role from business_node_approval_role
            <where>
                organ_id=#organId and business_id=#businessId and !isnull(next_approval_role)
            </where>
    </select>

修改之后重新启动项目再次测试接口

解决

以上是关于mytbatis mapper.xml报错:java.lang.UnsupportedOperationException] with root cause的主要内容,如果未能解决你的问题,请参考以下文章

报错,Result Maps collection already contains value for

Mybatis中Mapper.xml 文件使用注释遇到的坑

Mybatis中Mapper.xml 文件使用注释遇到的坑

MytBatis错题分析

解决找不到mapper.xml文件的问题

Invalid bound statement (not found): com.example.demo.mapper.B18040208Mapper.search