Features and advantages of Mybaits

  • 2020-05-26 08:32:50
  • OfStack

What is mybatis and what are the features of mybatis? Let's first introduce the concept and features of mybatis.

Advantages and disadvantages of jdbc development:

1) advantages: easy to learn, quick to get started, very flexible to build SQL, high efficiency

2) disadvantages: cumbersome code, difficult to write high-quality code (such as resource release, SQL injection security, etc.)
Developers write both business logic and object creation and destruction, regardless of the syntax of the underlying concrete database
(e.g. Paging).

3) it is suitable for the operation of super large quantities of data with fast speed

Advantages and disadvantages of hibernate development:

1) advantages: no need to write SQL, completely object-oriented design and access, regardless of the underlying concrete database syntax (e.g., paging) easy to understand.

2) disadvantages: when dealing with complex business, the flexibility is poor, and complex HQL is difficult to write and understand, such as HQL statement for multi-table query

3) it is suitable for the operation of small and medium batch data, and the speed is slow

1) based on the above two supports, do we need to find a balance point in the middle? Combine their advantages and discard their disadvantages,

This is myBatis, and today myBatis is widely used by businesses.

2) MyBatis was originally an open source project of apache, iBatis. In 2010, this project was transferred from apache software foundation to google code and renamed MyBatis. Moved to Github in November 2013.

3) the word iBATIS1 comes from the combination of "internet" and "abatis" and is a persistent layer framework based on Java. The persistence layer framework provided by iBATIS includes SQL Maps and Data Access Objects (DAO)

4) jdbc/dbutils/springdao, hibernate/springorm, mybaits belong to ORM solution 1

Ok, let me give you a brief introduction of the features and advantages of Mybaits. The details are as follows:

1. Separate the SQL statement from the code

Easy to manage and maintain, no need to adjust the SQL statement in the Java code. However, when the SQL statement is wrong, the console will not print Log.

Solution -- quote log4j

2. Splicing SQL statements with tags

Although it is much easier to write simple SQL statements, complex statements are difficult to concatenate

3. Automatic mapping of result set and JAVA objects

As anyone who has written hibernate knows,hibernate automatically generates the database entity class and its mapping file when it connects to the database to generate SQL statements
High, entity classes and configuration files need to be handwritten.

4. Instant loading

When a large amount of data is displayed on one page at a time, the delayed loading of hibernate creates a large number of proxy classes and consumes resources.mybaits does not access the database through delay.


Related articles: