In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces "what are the advantages and disadvantages of MyBatis". In daily operation, I believe many people have doubts about the advantages and disadvantages of MyBatis. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful for you to answer the doubts about "what are the advantages and disadvantages of MyBatis?" Next, please follow the editor to study!
What is MyBatis
It is an excellent Java-based persistence layer framework that supports customized SQL, stored procedures, and high-level mapping.
The persistence layer framework provided by MyBatis includes SQL Maps and Data Access Objects (DAO), avoiding almost all JDBC code and manually setting parameters and getting result sets. MyBatis can use simple XML or annotations for configuration and native Map to map interfaces and Java POJOs (Java objects) to records in the database.
How to install MyBatis
MyBatis is easy to install, as long as you put the mybatis-x.x.x.jar file in classpath.
If you use Maven to build the project, you need to put the following dependency code in the pom.xml file:
Org.mybatis mybatis x.x.x III. MyBatis functional architecture
The functional architecture of Mybatis is mainly divided into three layers:
API interface layer: provides external use of the interface API, developers through these local API to manipulate the database. As soon as the interface layer receives the call request, it will call the data processing layer to complete the specific data processing.
Data processing layer: responsible for specific SQL lookup, SQL parsing, SQL execution and result mapping processing. Its main purpose is to complete a database operation according to the called request.
Basic support layer: responsible for the most basic functional support, including connection management, transaction management, configuration loading, and caching, which are common things, extracted as the most basic components. It provides the most basic support for the upper data processing layer.
IV. Advantages and disadvantages of MyBatis
Advantages:
1. Easy to learn: small and simple. No third-party dependence, simple installation, as long as two jar files + configuration of several sql mapping files can be, easy to learn, easy to use, through documentation and source code, you can fully grasp its design ideas and implementation.
two。 Flexibility: mybatis does not impose any impact on the existing design of the application or database. Sql is written in xml for unified management and optimization. With sql, we can basically achieve all the functions that we can achieve without using the data access framework.
3. Uncoupling sql and program code: by providing DAL layer, the business logic and data access logic are separated, so that the design of the system is clearer, easier to maintain and easier to unit test. The separation of sql and code improves maintainability.
4. Provides mapping tags to support the mapping of the orm field relationship between objects and the database.
5. Provide object-relational mapping tags to support object-relational construction and maintenance.
6. Provide xml tags to support the writing of dynamic sql.
Disadvantages:
1. Writing SQL statements takes a lot of work, especially when there are many fields and associated tables.
2. The SQL statement depends on the database, which leads to the poor portability of the database and cannot replace the database.
3. The framework is still relatively simple, the function is still missing, although it simplifies the data binding code, but the entire underlying database query actually has to be written on its own, the workload is also relatively large, and it is not easy to adapt to rapid database modification.
4. The secondary caching mechanism is not good.
At this point, the study of "what are the advantages and disadvantages of MyBatis" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.