Mybatis - Basics

    mybatis is a java persistence layer framework, and jdbc is used to operate relational databases in java, and mybatis is an encapsulation of jdbc.

 

Introduction

          The term iBATIS comes from the combination of "internet" and "abatis" and is a Java-based persistence layer framework. The persistence layer framework provided by iBATIS includes SQL Maps and Data Access Objects (DAOs).

        The predecessor of MyBatis was called iBatis , which was an open source project of apache . In 2010, the project was migrated to google code from the apache software foundation and renamed MyBatis. Migrated to Github in November 2013. MyBatis is an excellent persistence layer framework that supports plain SQL queries, stored procedures and advanced mappings. MyBatis eliminates almost all JDBC code and manual setting of parameters and retrieval of result sets. MyBatis uses simple XML or annotations for configuration and primitive mapping to map interfaces and Java POJOs (Plan Old Java Objects, common Java objects) to records in the database.

        git (distributed version control, current comparison process)

    MyBatis is an excellent persistence layer framework. It encapsulates the process of operating the database of jdbc, so that developers only need to pay attention to SQL itself, and do not need to spend energy to deal with such as registering drivers, creating connections, creating statements, manually setting parameters, Result set retrieval and other jdbc complex process code.

    Mybatis configures the various statements to be executed (statement, preparedStatemnt, CallableStatement) through xml or annotation, and maps the java object and the sql in the statement to generate the final executed sql statement. Finally, the mybatis framework executes the sql and generates the result. Map to java object and return.   

    The functional architecture of Mybatis is divided into three layers:

1) API interface layer: The interface API provided for external use, and the developer manipulates the database through these local APIs. As soon as the interface layer receives the call request, it will call the data processing layer to complete the specific data processing.

2) Data processing layer: responsible for specific SQL search, SQL parsing, SQL execution and execution result mapping processing, etc. Its main purpose is to complete a database operation according to the call request.

3) Basic support layer: Responsible for the most basic functional support, including connection management, transaction management, configuration loading and cache processing, these are all common things, and they are extracted as the most basic components. Provide the most basic support for the upper data processing layer.


    mybatis architecture



1. Start with a jdbc program and find the original jdbc development program through the jdbc program. What are the problems? ? By learning mybatis, how mybatis solves these problems.

2. The architecture of mybatis (focus)

3. The entry program of mybatis (focus)

         Realize user query, add, modify, delete.

4. Two methods for mybatis to develop dao. (emphasis)

         The original dao development method (both dao interface and dao implementation need to be written)

         mapper proxy mode (only need to write dao interface) 

5. Input mapping type and output mapping type. 

6. Dynamic SQL


Advanced knowledge 

         Advanced mapping query (one-to-one, one-to-many, many-to-many) (emphasis)

         query cache

         lazy loading

         mybatis and spring integration (emphasis)

         mybatis reverse engineering.


If you need to learn MyBatis completely, you can click to download [ Complete MyBatis Study Notes ]
After writing Spring+MyBatis+Spring MVC and other articles, I have compiled a set of [ Complete Practical Documents ] , click to download if necessary

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325586031&siteId=291194637