mybatis insert data returned id, a feature that took me a long time, I really feel very values, Baidu although many articles written method but did not write the most important step has now been almost 21 o'clock, I used the last few minutes to help we do not make detours, many online first answer is correct, but the most important thing , "is the id need to get to, controller layer is not acquired in the service layer", "we must pay attention to this
The following code is attached screenshot, a total of two methods are available, hopes are detours, then there are sure to share knowledge, said knowledge is wholly or bullying. .
First, this is the most important one, returns the id of the service in
two, the first way
Third, the second way