Mybatis:Mapper methodattempted to return null from a method with a primitive return type (int)

it2023-01-06  83

Mybatis中 Mapper method attempted to return null from a method with a primitive return type (int)错误

本人是在进行插入操作的时候发生的错误,相应的删除和修改都是同样的道理

<select id="saveEmpInfo" resultType="int"> INSERT INTO emp(eId,eName,did) VALUES(#{eId},#{eName},#{did}) </select >

错误提示:

org.apache.ibatis.binding.BindingException: Mapper method 'com.xa.dao.EmpDaoMapper.saveEmpInfo attempted to return null from a method with a primitive return type (int).

正确写法:

<insert id="saveEmpInfo"> INSERT INTO emp(eId,eName,did) VALUES(#{eId},#{eName},#{did}) </insert>

原因分析

增加:<insert></insert> 删除:<delete></delete> 修改:<update></update> 查询:<select></select> 其中,增删改都不需要添加resultType="int"

效果:

修改前: 修改后: 修改日志: 由图可见:eId为16的员工信息发生了修改

最新回复(0)