1. Schematic diagram and layered architecture

2. Initialization of SqlSessionFactor

Parses the configuration file information and saves it in the Configuartion object, returning the DefaultSqlSeesion object

Flow chart:

3. Obtain the sqlSession object

Step 1: DefaultSqlSeesion calls the openSession method

Flow chart:

4. GetMapper of the sqlSession object obtains the proxy object of the interface

Generating proxy objects

Flowchart: Finally returns a proxy object, MapperProxy

5. Use MapperProxy to implement query

Four objects of Mybatis:

  • Executor: MyBatis Executor, used to perform add, delete, change, and query operations
  • StatementHandler: Processing object of the database, used to execute SQL statements
  • ParameterHandler: Parameter objects that process SQL
  • ResultSetHandler: Processes the returned result set of SQL