Mybatis is an excellent persistence layer framework. The bottom layer realizes the interaction with the database based on JDBC. It is encapsulated and optimized on the basis of JDBC operation. With the help of flexible SQL customization and the mapping of parameters and result sets, it better adapts to the development of current Internet technology.
Mybatis can use simple XML or annotations to configure and map native types, interfaces, and Java POJOs to records in the database.
Mybatis application builds sqlsessionfactory (sqlsessionfactory is thread safe) from mybatis-config.xml configuration file through sqlsessionfactorybuilder (it can also be configured by java file, and @ configuration needs to be added);
Then, the instance of sqlsessionfactory directly opens a sqlsession, obtains the mapper object through the sqlsession instance, runs the SQL statement of mapper mapping, completes the crud and transaction submission to the database, and then closes the sqlsession.