今天在使用mybatis时遇到这个问题,在此记录一下,希望能帮到你们保措施collection does net contain value for java.lang.Integer
我的mapper文件里面写的是酱紫的
<select id="selectMaxFloorByPostid" parameterType="java.lang.Integer" resultMap="java.lang.Integer">
select
max(floorPosition)
from forumfloor
where floorPostid = #{postid,jdbcType=INTEGER}
</select>
我本意事项从表中某个字段查询出其最大值,阿哥字段是int类型,想当然返回类型是Integer类型,所以在resultMap="java.lang.Integer",但是跑起来之后发现时不对的,
collection does net contain value for java.lang.Integer就这样出现了,解决办法就是去掉resultMap="java.lang.Integer",至于对应java代码中的selectMaxFloorByPostid方法的翻译类型你就写Integer就行了,它自动会识别的。有不对的地方欢迎指正。