使用 MyBatis,怎么优雅地获取到 insert 时自动生成的 id?
資深大佬 : JasonLaw 9
我找了一些资料,比如说java – MyBatis, how to get the auto generated key of an insert? [MySql] – Stack Overflow中的一个回答,但是太丑陋了,有优雅一点的方法吗?
大佬有話說 (4)
我找了一些资料,比如说java – MyBatis, how to get the auto generated key of an insert? [MySql] – Stack Overflow中的一个回答,但是太丑陋了,有优雅一点的方法吗?
@Insert(“insert into table2 (name) values(#{name})”)
@SelectKey(statement=”call identity()”, keyProperty=”nameId”, before=false, resultType=int.class)
int insertTable2(Name name);
“`