In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article is to share with you about the ways mybatis can read mapper files. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
What are several ways for mybatis to read mapper files? What's the priority?
Priority: package > resource > url > class
There are several ways to exectuor mubatis
SimpleExecutor: simple executor, which is the default executor in MyBatis. Every time update or select is executed, a Statement object is opened, and the Statement object (which can be Statement or PreparedStatment object) is closed directly after use.
ReuseExecutor: reusable executor. Reuse here refers to the reuse of Statement, which internally uses a Map to cache all the created Statement. Each time the SQL command is executed, it determines whether there is a Statement object based on that SQL. If there is a Statement object and the corresponding connection is not closed, continue to use the previous Statement object and cache it. Because each SqlSession has a new Executor object, the Statement scope we cache on the ReuseExecutor is the same SqlSession.
BatchExecutor: batch executor for outputting multiple SQL to a database at one time
CachingExecutor: cache executor, which first queries the result from the cache and returns it if it exists. If it does not exist, it is delegated to Executor delegate to fetch it from the database. Delegate can be any of the above executors.
Is the first-level cache of mybatis enabled by default? How do you use it if it is turned on?
First-level caching is enabled by default because of cacheEnabled. Generate cached key through four attributes of id offset limit sql
The first-level cache is implemented through HashMap, and its key object is composed of SQL's ID, parameters, SQL itself, paging parameters and JDBC parameter information.
Second-level cache is mapper-level cache, multiple SqlSession to operate the same Mapper sql statements, multiple SqlSession to operate the database to get data will exist in the secondary cache area, multiple SqlSession can share secondary cache, secondary cache is cross-SqlSession.
The second-level cache is shared by multiple SqlSession, and its scope is the same namespace of mapper. After the first execution, the data queried in the database will be written to the cache (memory), and the second time the data will be obtained from the cache will no longer be queried from the database, thus improving the query efficiency.
Mybatis does not enable secondary cache by default. You need to enable secondary cache in the global parameters of setting.
If there is data in the cache, there is no need to get it from the database, which greatly improves the performance of the system.
It is not recommended to use secondary cache with different namespace to operate on the same table, which will lead to data confusion.
An inside examination question: a system passes system B a sql how to judge whether sql is correct or sql?
What is the orm framework? It is used to realize the data conversion between different types of systems in object-oriented programming language.
Thank you for reading! This is the end of this article on "how many ways are there for mybatis to read mapper files". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it out for more people to see!
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.