Mybatis is an excellent persistence layer framework that supports customized SQL, stored procedures, and advanced mapping. 2.MyBatis avoids almost all JDBC code and manually setting parameters and fetching result sets. MyBatis can use simple XML or annotations for configuration and original mapping to map interfaces and Java’s POJOs (Plain Old Java Objects) to records in the database. Simple comparison of the previous code is to write the SQL statement before the unified XML file, we do not need to write dao layer implementation class, convenient for us to find SQL, we do not need to write JDBC code, as long as the configuration can be used.
1.2. Mybatis was originally an open source project of Apache iBatis. In June 2010, this project was migrated to Google Code by Apache Software Foundation. Ibatis3. x was officially renamed Mybatis and the code was migrated to Github in November 2013 (download address below). The term iBATIS comes from the combination of “Internet” and “Abatis”. IBATIS is a Java-based persistence layer framework. IBATIS provides persistence layer frameworks including SQL Maps and Data Access Objects (DAO)
1.3. Why to use Mybatis? 1.MyBatis is a semi-automated persistence layer framework. JDBC Programming – WHEN we use JDBC persistence, SQL statements are hard-coded into Java code. This coupling is too high. The code is not easy to maintain. In actual project development, SQL is often added or modified so that we can only modify it in Java code.
2.Hibernate and JPA long difficult complex SQL, for Hibernate processing is not easy to internal automatic production of SQL, not easy to do special optimization. Based on the fully automatic framework of full mapping, Javabeans cannot map only part of a large number of fields. The database performance deteriorates.
3. For developers, the core SQL still needs to optimize SQL and Java coding separate, clear functional boundary, one focus on business, one focus on data. You can use simple XML or annotations for configuration and raw mapping to map interfaces and Java POJOs to records in the database. Become the medium for business code + underlying database
You can go to the official Chinese document of Mybatis
Learn about the four major parts of MyBatis in advance