mybatis中使用查询max()函数返回-1

我要查询表中某个列的最大值:

<insert id="selectMaxVersionByType">
select
max(version)
from aton_agreement
where type = #{type}
</insert>

结果一直返回-1

改成以下形式:

<select id="selectMaxVersionByType" resultType="java.lang.Integer">
select
max(version)
from aton_agreement
where type = #{type}
</select>

结果返回正确


版权声明:本文为liushuyul原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。