<select id="checkPass" parameterType="java.util.Map" resultType="java.util.List">
select user_id from t_user_info tcc
<trim prefix="where" prefixOverrides="and|or">
<if test="cpIds!=null">
and tcc.user_id in
<foreach collection="cpIds" index="index" item="cpId" open="(" separator="," close=")">
#{cpId}
</foreach>
</if>
</trim>
group by user_id
</select>
预期是想返回user_id的集合,所以resultType用的是java.util.List
执行报错:
Caused by: org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause: java.lang.UnsupportedOperationException
### The error may exist in
### The error occurred while handling results
### SQL: select user_id from t_user_info tcc where tcc.user_id in ( ? ) group by user_id
查阅List相关返回需要需设置List中对应的属性就可以
修改为如下执行正常
<select id="checkPass" parameterType="java.util.Map" resultType="java.util.Long">
select user_id from t_user_info tcc
<trim prefix="where" prefixOverrides="and|or">
<if test="cpIds!=null">
and tcc.user_id in
<foreach collection="cpIds" index="index" item="cpId" open="(" separator="," close=")">
#{cpId}
</foreach>
</if>
</trim>
group by user_id
</select>
resultType是sql映射文件中定义返回值类型,返回值有基本类型,对象类型,List类型,Map类型等。现总结一下再解释
总结:
resultType:
1、基本类型 :resultType=基本类型
2、List类型: resultType=List中元素的类型