In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces you how to understand Hiberate3 Session cache, the content is very detailed, interested friends can refer to, hope to be helpful to you.
Hiberate3 has a lot to learn, and here we focus on Hiberate3 Session caching, including the differences between List () and iterate queries.
1.Hiberate3 Session cache, which is bound to session. Its life cycle is the same as that of session. Session destroys, it also destroys at the same time; manage first-level cache, first-level cache cannot be cancelled, use two methods to manage, clear (), evict ()
two。 The two session cannot share a first-level cache because it will accompany the creation and destruction of the session lifecycle
3.Hiberate3 Session caching is entity-level caching, which is used only when querying the object level. If HQL and SQL are used at the query attribute level, first-level caching is not used! Remember!
If 4.iterate query uses cache, it will issue SQL and HQL statements to query Id, but will not issue query entities. After query, it will put the corresponding entities in the cache. Some entity queries will be queried from the cache if there are in the cache, but will still issue SQL and HQL statements to query id. If it is not in the cache, it will be queried in the database, and then the queried entities will be put into the cache one by one, so there will be Number1 problems.
The difference between 5.List () and iterate queries:
Using iterate,list to query entity objects * Number1 problems can occur by default when using query.iterate queries. The so-called Number1 query issues a sql statement when querying. 1: first issue a sqlN that queries the id list of objects:
According to the id list to the cache query, if there is no matching data in the cache, then the corresponding sql statement list and iterate will be issued according to id.
List issues a sql statement every time, and list puts data into the cache without using the data in the cache. Iterate: by default, iterate makes use of cached data, but if there is no data in the cache, it can cause Nation1 problems.
Both 6.Get () and load (), iterate methods use first-level caching
The 7.hiberate3 session stored procedure is as follows:
For example, object object
◆ Session.save (object)
At this time, the data will not be put into the database, but will be put into the session cache first. There is no corresponding record in the database.
◆ session.flush (); has just issued SQL and HQL statements, and there are corresponding records in the database.
But the database cannot be found with select, which has something to do with the transaction level of the database.
◆ Session.beginTrransaction (). Commit ()
Things can be queried after they have been submitted.
◆ Session.flush () statement but why not write it, because commit () calls flush () by default
On how to understand Hiberate3 Session cache to share here, I hope that the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it 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.