The examples on the Internet are simple, as long as the use of Usegeneratedkey on the line.
@Insert ({"Insert into money_record_increasement (ID, createtime) VALUES (null, #{createtime})" }) True, Keyproperty = "id") int insertmoneyrecordincreasement (moneyrecordincreasement Record);
But if the variable returned by this int is used directly, the discovery is 1, that is, the successful return of 1. The returned primary key cannot be used this way ... The primary key returned is obtained from the inserted object. As follows
New moneyrecordincreasement (); Moneyrecordincreasement.setcreatetime (createtime); int id = moneyrecordincreasementmapper.insertmoneyrecordincreasement (moneyrecordincreasement); return Moneyrecordincreasement.getid ();
Here ID is the success of the indicator, to return the primary key ID, need to get from the object ....
MyBatis return PRIMARY Key