Stage 3 1.Mybatis_05. CRUD_2 Mybatis use Mybatis complete the save operation CRUD-

Added methods


Modify map configuration

id is the name of the method



according to the original wording values jdbc there should be a bunch of question marks, here and now can not go to a written question mark as to the value

passed from the way we want to perform parameter values to go inside

so we type parameter you must tell the sql statement execution
type parameterType User parameter is the type

to take over where we want to provide user value inside the sql statement.
# {}

Because entity class getter and setter our program are automatically generated, so here you can write directly to the properties of the entity class

Test Methods

Sex is the sex of the length of a char type



code means to query the above test copied. Issued the final call here the name was changed to saveUser method,



follow-up tests will be some of this long-winded code. A lot of trouble
to put forward a common way to put inside init

again a method used to release resources.


Two notes, he will be in the square before and after the implementation and execution method is invoked.

userDao statement has not been deleted. Here deleted.



The method of execution of the query

calls saveUser method

does not commit the transaction, there has been rolled back. Although the code is no exception, but saving can not be achieved

Commit the transaction





Why not 49 yet, just because the transaction is rolled back.

The transaction is committed, is moved before the release of resources. It has pledged to support each commit transaction
 

Guess you like

Origin www.cnblogs.com/wangjunwei/p/11307301.html