Characteristics and advantages of mybaits

What is mybatis and what are its characteristics? Let's introduce the concept and characteristics of mybatis.

Advantages and disadvantages of JDBC development:

1) Advantages: easy to learn, quick to start, very flexible to build SQL and high efficiency

2) Disadvantages: the code is cumbersome and it is difficult to write high-quality code (such as resource release, SQL injection security, etc.). Developers must not only write business logic, but also write the creation and destruction of objects. They must manage the syntax of the underlying specific database (such as paging).

3) It is suitable for the operation of large batch data with high speed

Advantages and disadvantages of Hibernate development:

1) Advantages: without writing SQL, it is designed and accessed completely in an object-oriented manner, regardless of the syntax of the underlying specific database (e.g. paging), which is easy to understand.

2) Disadvantages: when dealing with complex business, the flexibility is poor, and the complex HQL is difficult to write and understand, such as the HQL statement of 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 kinds of support, do we need to find a balance point in the middle? Combine their advantages and abandon their disadvantages,

This is mybatis. Nowadays, mybatis is adopted by a wide range of enterprises.

2) Mybatis was originally an open source project ibatis of Apache. In 2010, the project was migrated from Apache Software Foundation to Google Code and renamed mybatis. Moved to GitHub in November 2013.

3) Ibatis comes from the combination of "Internet" and "abatis". It is a persistence 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 and mybaits are all part of ORM solutions

Well, let's briefly introduce the characteristics and advantages of mybaits. The specific contents are as follows:

1. Separation of SQL statement and code

It is convenient for unified management and maintenance. There is no need to adjust SQL statements in Java code. However, when the SQL statement makes an error, the console will not print the log,

Solution -- reference log4j

2. Splice SQL statements with labels

Using tags instead of Java code is much more convenient when writing simple SQL statements, but it is difficult to splice complex statements

3. Automatic mapping of result set and Java object

Anyone who has written hibernate knows that when hibernate connects to the database to generate SQL statements, it will automatically generate database entity classes and their mapping files In mybaits, it helps us do this However, there are high requirements for database fields, and entity classes and configuration files need to be handwritten

4. Instant loading

When a large amount of data is displayed on a page at the same time, the delayed loading of Hibernate will create a large number of proxy classes and consume resources Mybaits does not access the database through latency

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>