In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly shows you "what is the meaning of mybatis", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "what does mybatis mean" this article?
What is mybatis:
Mybatis is essentially a semi-automated ORM framework, formerly known as ibatis, which requires some sql statements in addition to pojo and mapping relationships.
What to think of the ORM framework:
To deal with contradictions, java programmers like object-oriented development and interface-oriented development, while the database is composed of tables and libraries, the relationship between the two is difficult to reconcile, and relational mapping solves this problem.
Three elements of the Mybatis mapping file:
SQL
Mapping rule
Pojo .
Why use mybatis instead of hibernate?
In our Internet environment, we often have to face huge amounts of data, so we have to be based on the underlying tuning capabilities, that is, sql statements. The sql statements generated by hibernate are opaque.
There are three stages of Mybatis core process:
In the initialization phase, the configuration information in the XML configuration file and comments is read, the parsing object is created, and the initialization of each module is completed. Is to load our configuration file into memory. Loaded into memory during sqlSession initialization
Agent phase, encapsulating the programming model of iBatis and initializing the development using mapper interface
In the data reading and writing stage, the parsing of SQL, the mapping of parameters, the execution of SQL and the reflection parsing of the results are completed by SqlSession.
SqlSession
SqlSession means to create a database session, representing a connection to the database
It is the main API for mybatis to provide data access.
In fact, the functions of SqlSession are all based on Excutor.
The two programming models of Mybatis Mybatis encapsulate the ibatis programming model and use sqlsession to provide access to the database. The other is to use mapper interface programming to access the database.
The difference between Mybatis and ibatis
Mybatis was formerly owned by ibatis, and ibatis was previously owned by Apache and later by Google, but Google found it troublesome to implement ibatis, required to maintain static variables, and had no business meaning. So Google changed to mybatis, through the interface-oriented approach, so that all the code has business meaning, shielding the complexity of the underlying code.
Why can you access the database using the mapper interface?
In fact, in the end, it turns to the underlying ibatis execution method, which uses configuration file interpretation + dynamic proxy, finds the corresponding method execution in session, and finds the namespace and method name of the method. Pass parameters.
The business process starts with instantiating sqlssessionFactory, loading database configuration files, and mapper.xml into configuration objects. Then get the sqlsession object. Then through the dynamic agent to bridge the gap between interface-oriented programming and ibatis programming, and finally follow the jdbc specification, through the underlying four objects to complete the function.
The above is all the contents of this article "what does mybatis mean?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
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.