What is mybatis and what are the characteristics of mybatis? Let me first introduce the concept and characteristics of mybatis to you.
Advantages and disadvantages of jdbc development:
1) Advantages: Simple and easy to learn, quick to get started, very flexible to build SQL, 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 need to write both business logic and object creation and destruction, and they must manage the syntax of the underlying specific database (for example: pagination).
3) Suitable for operation of ultra-large batch data, fast speed
Advantages and disadvantages of hibernate development:
1) Advantages: No need to write SQL, it is designed and accessed completely in an object-oriented way, and does not need to worry about the syntax of the underlying specific database, (for example: pagination) is easy to understand.
2) Disadvantages: When dealing with complex businesses, it has poor flexibility and is difficult to write and understand complex HQL, such as HQL statements for multi-table query
3) Suitable for small and medium batch data operation, slow speed
1) Based on the above two support, do we need to find a balance point in the middle? Combining their advantages and abandoning their disadvantages,
This is myBatis, which is now adopted by a wide range of enterprises.
2) MyBatis is an open source project of apache. In 2010, this project was moved from apache software foundation to Google code and was renamed MyBatis. Migrated to Github in November 2013.
3) The term iBATIS comes from the combination of "internet" and "abatis", and is a Java-based persistence layer framework. iBATIS provides persistence layer frameworks including SQL Maps and Data Access Objects (DAO)
4) jdbc/dbutils/springdao, hibernate/springorm, mybaits are also one of the ORM solutions
Okay, let me briefly introduce the characteristics and advantages of Mybaits. The specific content is as follows:
1. Separation of SQL statements and code
It is convenient for unified management and maintenance, and there is no need to modular SQL statements in Java code. However, when SQL statements are wrong, the console will not print Log.
Solution--Cite log4j
2. Use tags to splice SQL statements
Although it is much more convenient to write simple SQL statements, it is difficult to splice complex statements.
3. Automatic mapping of result sets and JAVA objects
Anyone who has written hibernate knows that when hibernate connects to the database to generate SQL statements, it will automatically generate the database entity class and its mapping file. In mybaits, it helps us do this. However, the database fields are relatively high, and the entity class and configuration files need to be handwritten.
4. Instant loading
When a page displays a large amount of data at the same time, the delayed loading of hibernate will create a large number of proxy classes, consuming resources. Mybaits does not access the database through delayed access.