In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly explains the "characteristics and functions of MyBatis". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "the characteristics and functions of MyBatis".
What are the MyBatis characteristics?
1. Lightweight itself does not rely on any other JAR, but needs to provide a JDBC implementation
two。 Flexible and more suitable for Internet applications with frequently changing requirements
3. The cost of learning is low, and it is easy to master the use of MyBatis compared to the ORM framework.
What is the position of MyBatis in the structure?
MyBatis is in the position of DAO (data access object). Review the job responsibilities of DAO:
Connect to the database
Receive input data
Splice and execute SQL
Parse and return the result
What can MyBatis do?
There are the following problems with using JDBC to complete the DAO layer
Each operation requires manual creation of the connection, and finally closes the connection
Developers usually encapsulate duplicate code, but there is no fixed pattern for encapsulated code due to everyone's different coding styles.
MyBatis puts the parameters related to the database connection into the configuration XML and encapsulates the code to create the connection
Frequent creation and destruction of connections
Because the database connection uses TCP persistent connection, in the system with large concurrency, this way will lead to the depletion of database connection resources.
MyBatis itself implements connection pooling, which can solve this problem. Of course, other better connection pooling will be replaced later.
Accept parameters to splice SQL statements and execute
Each SQL statement is written directly in the code (hard-coded). If the requirements change later, you need to modify the SQL in the source code, and then recompile and test.
MyBatis strips the SQL statement from the code into the Mapper.xml mapping file
Analytical results
JDBC returns ResultSet, which must be manually mapped to one object after another, which is also highly repetitive code; and there are hard coding problems
MyBatis implements mapping of input parameters to SQL parameters and mapping of result sets to POJO objects.
Thank you for your reading, the above is the content of "the characteristics and functions of MyBatis". After the study of this article, I believe you have a deeper understanding of the characteristics and functions of MyBatis, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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.