The selectKey of ibatis is used to insert data and obtain the id. Some sequence data is used when ibatis is used to insert data into the database. In some cases, after the insertion is complete, you must return the sequence value before proceeding to the next step. Use the selectKey of ibatis to obtain the sequence value and return the value. However, there are different operations for different databases. For oracle: <insert id = "insertUser" parameterClass = "ibatis. user "> <selectKey resultClass =" long "keyProperty =" id "> select SEQ_USER_ID.nextval as id from dual </selectKey> insert into user (id, name, password) values (# id #, # name #, # password #) </insert> after the statement is executed, the id field in DO of the passed parameter User object will be assigned the sequence value. For mysql <insert id = "insertUser" parameterClass = "ibatis. user "> insert into user (name, password) values (# name #, # password #) <selectKey resultClass =" long "keyProperty =" id "> SELECT LAST_INSERT_ID () as id </selectKey> </insert> put selectKey after insert, and use LAST_INSERT_ID () to obtain the value of the newly inserted auto-increment id.