问题描述
idea使用mybatis插件mapper中的方法爆红,resultType返回的是实体类,项目能正常运行。
提示:Result type doesn't match for Select id="test"
mapper:
public interface TestMapper {
@MapKey("code")
Map<String, CategoryScaleVo> test();
}
xml:
<select id="test" resultType="com.test.model.vo.CategoryScaleVo">
select category as code, count(1) as count from advise
GROUP BY category
</select>
解决方案:
resultType换成resultMap
<resultMap id="categoryScaleMap" type="com.test.model.vo.CategoryScaleVo">
<result column="code" property="code"/>
<result column="count" property="count"/>
</resultMap>
<select id="test" resultMap="categoryScaleMap">
select category as code, count(1) as count from advise
GROUP BY category
</select>
这样就不会爆红了