Briefly describe the architecture of MyBatis and the architecture of mybatis.
The architecture of MyBatis consists of the following key components;
1. load configuration
There are two types of configuration: xml configuration file, the other is the java code annotation MyBatis which loads the SQL configuration information into MappedStatement objects (including input parameter ing configuration, execution of SQL statements, and result ing configuration ), and store it in memory.
2. SQL Parsing
When the API interface layer receives a request, it receives the ID and object of the input SQL statement (Map, javabean, or basic data type can be used ), myBatis will find the corresponding MappedStatement Based on the SQL id, and then parse the MappedStatement based on the input parameter object. After parsing, the final SQL statement and parameters to be executed can be obtained.
3. SQL Execution
Obtain the final SQL statements and parameters to the database for execution and obtain the database operation results.
4. Result ing
Convert the result of the Operation database according to the ing configuration. You can convert the result to HashMap, JavaBean, or based on the data type, and return the final result.