Tag Archives: BindingException: Mapper method ‘xxx.dao.StudentDao.insertStudent’ attempted to return null from a method with a primitive return type (int).

BindingException: Mapper method ‘xxx.dao.StudentDao.insertStudent’ attempted to return null from a method with a primitive return type (int).

1、 Question

Error reporting result:

  2、 Cause error code

The error I caused was caused in the Dao/studentdao.xml file, that is, the Dao configuration file of the persistence layer was written incorrectly. Here is my error code:

    <select id="insertStudent">
        insert into student1(name, age) values (#{name}, #{age})
    </select>

The reason for the error is that it is easy for novices to make a mistake. Writing the inserted data label as the label of query data leads to an error

  3、 Solution

Correct code

    <insert id="insertStudent">
        insert into student1(name, age) values (#{name}, #{age})
    </insert>