· By default, MyBatis allows plug-ins to intercept method calls of Executor (update, query, flushStatements, commit, rollback, getTransaction, close, isClosed)
· 、MyBatis Generator (A)MyBatis Generator 1.; 2.; 3.XML; 4.XMLJava(
· The MyBatis SQL mapper framework makes it easier to use a relational database with object-oriented applications. MyBatis couples objects with stored procedures or SQL statements using a XML descriptor or annotations. Simplicity is the biggest advantage of the MyBatis data mapper over object relational mapping tools.
The iBatis (MyBatis) Custom Data Type Wizard creates a Custom Data Type and Custom Type Handler for a selected Teradata Database data type to use with the iBatis or MyBatis framework.. iBatis and MyBatis support custom types to override JDBC and other types when using the iBatis or MyBatis framework. A custom data type enables you to handle a JDBC type with custom processing or allows
· Mybatis plug-in is also called interceptor. Mybatis adopts the chain of responsibility model to organize multiple plug-ins (interceptors) through dynamic agents, through which the default behavior of Mybatis can be changed. MyBatis allows you to intercept calls at a certain point during the execution of the mapped statement.
· Add plug-ins before executing sql to complete paging function Before executing the sql statement of the query, add a line of code PageHelper.startPage(1, 10) the first parameter represents the page number, and the second parameter represents the number of records displayed per page.
· JSON support for Mybatis 3.x using Gson 2.x. Provide support for JSON like field types in any Database. I'm developed this handler with PostgreSql in mind, but it looks like it can be used with any other database even without JSON support. Artifact does not include direct gson dependenciesit is up to you to add them into your project.
· mybatis- geneator mybatis ,,mapperxml。. pom
· 4、. MyBatis MyBatis 。. . configuration() properties() settings() typeAliases() typeHandlers() objectFactory() plugins() environments
· Mybatis ,、 typeAliases , Entity typeHandlers JDBC Types Java Types ,Mybatis ,。
· Note that the basic types (int, boolean, etc.) cannot be set to null. true,false false logPrefix Specify that MyBatis is added to the prefix of the log name. Any String Not set logImpl Specify the specific implementation of the logs used by MyBatis, which will
· background . Now it's more and more popular based on SpringBoot Development web application , Which uses mybatis As a database CRUD Operation has become the mainstream , The building owner mysql For example , Nine types of usage are summarized mybatis Operating the database sql Tips to share with you .. Paging query preset sql Query field A pair of multi-level joint queries
· plugins plug in. Plug in is a very powerful mechanism provided by MyBatis. It can modify some core behaviors of MyBatis through plug-in. Plug in uses dynamic proxy mechanism to intervene in the execution of any method of four objects (Executor, ParameterHandler, ResultHandler, StatementHandler). To be added. environments
· background . Now it's more and more popular based on SpringBoot Development web application , Which uses mybatis As a database CRUD Operation has become the mainstream , The building owner mysql For example , Nine types of usage are summarized mybatis Operating the database sql Tips to share with you .. Paging query preset sql Query field A pair of multi-level joint queries
· So when configuring these two different types of plug-ins , It must be done first Executor Interceptor , Then it's your turn StatementHandler. So in this case, the order in which interceptors are configured doesn't matter , stay MyBatis Logically, the order has been controlled .
· With this, you can create your own code generator and plug it in to the code generation engine. See the Extending MyBatis Generator page for more information. introspectedColumnImpl Use this value to specify the fully qualified name of a class that extends org.mybatis.generator.api.IntrospectedColumn. This is used if you want to change the behavior of the
4 ,。. 1)newExecutor -> interceptorChain.pluginAll(executor) 2)newStatementHandler -> interceptorChain.pluginAll(statementHandler) 3-1)newParameterHandler -> interceptorChain.pluginAll(parameterHandler) 3-2)newResultSetHandler ->
· background . Now it's more and more popular based on SpringBoot Development web application , Which uses mybatis As a database CRUD Operation has become the mainstream , The building owner mysql For example , Nine types of usage are summarized mybatis Operating the database sql Tips to share with you .. Paging query preset sql Query field A pair of multi-level joint queries
The iBatis (MyBatis) Custom Data type Wizard creates a Custom Data type and Custom handler for a selected Teradata database data type to use with the iBatis or MyBatis frameworks. The Generated Custom Type can be used with the following Teradata plug-in for Eclipse iBatis (MyBatis) Wizards to override the Teradata database types
· Mybatis Generator MBG , MyBatis ibatis。. pojo、Mapper、Mapper,QBC。. ,MyBatis GeneratorXMLCRUD,SQL。. https //github/mybatis/generator.
· 2. MyBatis cache classification. MyBatis has two types of cache first level cache and second level cache. (1) Level 1 cache SqlSession level. It is on by default and cannot be closed. When operating the database, you need to create a SqlSession object. There is a HashMap in the SqlSession object to store the cached data.
· JSON support for Mybatis 3.x using Gson 2.x. Provide support for JSON like field types in any Database. I'm developed this handler with PostgreSql in mind, but it looks like it can be used with any other database even without JSON support. Artifact does not include direct gson dependenciesit is up to you to add them into your project.
· mybatis-generator(MBG),,org.mybatis.generator.api.Plugin,org.mybatis.generator.api.PluginAdapter。. generatorConfig.xml
· In the previous section Spring Data JPA In, it mainly introduces how Spring Data JPA connects to the database, and how to add, delete, modify and query the data. In this section, we will integrate MyBatis, another commonly used Java persistence layer framework, with Spring Boot. Considering the wide application of MyBatis, MyBatis will be used as the main Java persistence layer
· In the previous section Spring Data JPA In, it mainly introduces how Spring Data JPA connects to the database, and how to add, delete, modify and query the data. In this section, we will integrate MyBatis, another commonly used Java persistence layer framework, with Spring Boot. Considering the wide application of MyBatis, MyBatis will be used as the main Java persistence layer
· MyBatis 3.4.0 with the following main features New Cursor List method in SqlSession. Inherit Spring timeout in transactions. Better support for generic types. Out-of-the-box support new Date and Time API (JSR-310) classes added in Java 8.
· mybatis-generator , model、xml , maven , maven ,pombuildplugins
· MyBatis eliminates almost all JDBC code and the work of setting parameters and getting result sets. MyBatis can configure and map primitive types, interfaces and Java POJO s (Plain Old Java Objects) as records in the database through simple XML or annotations. 2. Spring Boot integrates Mybatis. 2.1 introducing maven coordinates
· MyBatis eliminates almost all JDBC code and the work of setting parameters and getting result sets. MyBatis can configure and map primitive types, interfaces and Java POJO s (Plain Old Java Objects) as records in the database through simple XML or annotations. 2. Spring Boot integrates Mybatis. 2.1 introducing maven coordinates
· Types of database transaction management -->