Mybatis~The sql statement in the total inserts data into the table to get the id of the currently added data

1. Add the properties "useGeneratedKeys" and "keyProperty" to the Mybatis Mapper file, where keyProperty is the property name of the Java object, not the field name of the table

<insertid="insert"parameterType="实体名"useGeneratedKeys="true"keyProperty="id">         
        insert into system(name) values(#{name})    
</insert>  

Second, in the controller

       The id when adding the current row of data is obtained through the entity name.id

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326607969&siteId=291194637