[Mybatis Notes] Mybatis implements mysql addition, deletion, modification and search

The registration in namespace is consistent with the Dao/mapper interface

id: corresponds to the method name in the namespace

resultType: return value of sql statement execution

parameterType: parameter type


You only need to change the interface, the interface implementation class, the test class, and nothing else.

Example: Get user by id

interface 

Interface implementation class:

 

Test class:

 

 Example: Insert a user:

interface

 interface implementation class

 Test class:

 Note: The transaction must be submitted for additions, deletions, modifications and inquiries, sqlSession.commit();

Example: modify user

 

 

 Example: delete a user

 

 

 

Guess you like

Origin blog.csdn.net/m0_52043808/article/details/124347310