mybatis ways to prepare for annotations sql, when inserting a data record, the data is not inserted into the ID value needs to be returned from the growth ID value, when writing one line of code needs to be added.
DAO layer Code: TestDAO
@Insert("insert into tablename(handler,title) " +
"values(#{handler},#{title})")
@Options(useGeneratedKeys = true, keyProperty = "id")//添加该行,id值将自动添加到Measure
void insert(Measure measure);
Service-level code
testDAO.insert(measure);
long id = measure.getId();//取得id为自增长的值