How mybatis works


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.

Recommended Today

The selector returned by ngrx store createselector performs one-step debugging of fetching logic

Test source code: import { Component } from ‘@angular/core’; import { createSelector } from ‘@ngrx/store’; export interface State { counter1: number; counter2: number; } export const selectCounter1 = (state: State) => state.counter1; export const selectCounter2 = (state: State) => state.counter2; export const selectTotal = createSelector( selectCounter1, selectCounter2, (counter1, counter2) => counter1 + counter2 ); // […]