我正在努力学习MyBatis。使用注释插入语句后如何获取自动生成的 ID @Insert。
我的代码示例:
@Insert("INSERT INTO user(name, mobile, password) VALUES(#{name}, #{mobile}, #{password})")
@SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "id", before = false, resultType = Long.class)
Long insertUser(User user);
Run Code Online (Sandbox Code Playgroud)
我想获取生成的 id 作为插入方法的返回。