Mybatis new data

If the interface parameter is passed an object

 

 

If the parameter is a plurality of general interfaces pass parameters, not the target

Way: In the sql statement takes a value to the parameter by the index position of the interface method parameter

 

Second way: By custom interface method parameter name in a value to obtain the name of the custom parameter sql statement

 

 

 

Three ways: DAO interface method only receive a map type of parameters, all encapsulated into the data map is then transmitted to the sql statement, sql statement by map the acquired key data

 

 

 

 

Four ways: passing parameters dao interfaces with a plurality of both types of objects, there are basic types of universal manner []

 

 

Return value of the primary key of the new data after it is inserted into a data

mysql median then execute the following statement is executed after the insert statement, the primary key may be acquired insert data of

 

 

Inserting data Mybatis implemented and acquiring primary key value

 

 

Test acquired primary key value returned

 

 

Set the primary key value Mybatis executed after the new data to a property of the object, it is necessary to obtain the value of the primary key returned by calling the object attributes.

Guess you like

Origin www.cnblogs.com/Tunan-Ki/p/11780008.html