MyBatis used to insert a piece of data.
<insert id= "Insertlatlong" parametertype= "map" >
insert INTO gylatlong (UserID, longitude, latitude)
VALUES (#{userid}, #{longitude}, #{latitude})
</insert>
Of course, in fact, he would return 1 int values.
But this int will always be 1. As he returned to the fact that he had affected the number of rows,
When you insert a piece of data, he doesn't return the unique ID that you inserted into his data.
After checking the information on the Internet, we finally know
<insert id= "Inserttaxiorder" parametertype= "map" usegeneratedkeys= "true" keyproperty= "id" >
Insert Into tb_taxiorderinfo (UserID, DriverID, startaddress, Endaddress,publictime,startlongitude,startlatitude
VALUES (#{userid}, 0, #{startadd}, #{endadd}, GETDATE (), #{longitude}, #{latitude}
)
Plus usegeneratedkeys= "true" keyproperty= "ID"
That means. After he inserts, the ID of the inserted data will be automatically generated
Into the ID that you set behind this keyproperty.
You can just take the value of the ID after execution.
The ParameterType I received here is map.
So before the map has to have this key
If you receive an entity class, then of course the entity class will define the id attribute.