mybatis Chapter 1 Introduction to mybatis

1.mybatis history

MyBatis was originally iBatis, an open source project of Apache. In June 2010, this project was migrated to Google Code by the Apache Software Foundation. As the development team moved to Google Code, iBatis3.x was officially renamed MyBatis. The code was migrated to Github in November 2013.

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

The biggest feature of Mybatis: lightweight . Compared with Hibernate, it omits a large number of uncommon functions, making it overall lightweight and efficient.

2. Mybatis download address

https://github.com/mybatis/mybatis-3
Insert image description here
online document address https://mybatis.org/mybatis-3/zh/index.html

3. Mybatis features

  • MyBatis supports customized SQL, stored procedures and advanced mapping
  • MyBatis avoids almost all JDBC code and manual parameter setting and result set parsing operations
  • MyBatis can use simple XML or annotations to implement configuration and original mapping; map interfaces and Java POJO (Plain Ordinary Java Object, ordinary Java objects) into records in the database
  • Mybatis is a semi-automatic ORM (Object Relation Mapping) framework

4. Comparison with other persistence layer technologies

  • JDBC
    • SQL is mixed in Java code with a high degree of coupling, causing internal damage to hard coding.
    • Maintenance is difficult and SQL changes in actual development requirements, and frequent modifications are common.
    • Long code and low development efficiency
  • Hibernate and JPA
    • Easy to operate and high development efficiency
    • Long and complex SQL in the program needs to bypass the framework
    • The SQL automatically generated internally is not easy to perform special optimization.
    • Based on the fully automatic framework of full mapping, it is difficult to partially map POJOs with a large number of fields.
    • Too many reflection operations cause database performance to degrade
  • MyBatis
    • Lightweight, great performance
    • SQL and Java coding are separated and functional boundaries are clear. Java code focuses on business, SQL statements focus on data
    • The development efficiency is slightly lower than HIbernate, but it is completely acceptable.

Development efficiency: Hibernate>Mybatis>JDBC

Operating efficiency: JDBC>Mybatis>Hibernate

Guess you like

Origin blog.csdn.net/wyr1235/article/details/129090401