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 > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly shows you "Hibernate how to achieve a level of Cache", 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 "Hibernate how to achieve a level of Cache" this article.
Hibernate Cache has a lot to learn. Here we mainly introduce first-level Cache, including the implementation of *-level Hibernate Cache in Session, which belongs to transaction-level data buffering.
Hibernate implements a good Cache mechanism, which can rapidly improve the data reading performance of the system with the help of Cache in Hibernate. Cache in Hibernate can be divided into two layers: first-level Cache and second-level Cache.
First-level Cache:
Session implements * *-level Hibernate Cache, which belongs to transaction-level data buffering. Once the transaction is completed, the Cache also expires. The life cycle of an Session corresponds to a database transaction or a program transaction.
Session-cache ensures that when the same object is requested twice in a Session, the object obtained is the same JAVA instance, and sometimes it can avoid unnecessary data conflicts. In addition, it provides assurance for other important performance:
1: when making a self-circular reference to an object, there is no stack overflow.
2: when the database transaction ends, there is no data conflict for the same database row, because for a row in the database, there is at most one object to represent it.
3: there may be many processing units in a transaction, and the operations done in each processing unit will be immediately known by the other processing unit.
We don't have to open Session-cache deliberately, it is always opened and cannot be closed. When you use save (), update (), or saveOrUpdate () to save data changes, or to get an object through methods such as load (), find (), list (), etc., the object is added to the Session-cache.
If you want to synchronize many data objects, you need to manage Cache effectively, and you can use the evict () method of Session to remove objects from the first-level Cache. As follows:
Session session = HibernateUtil.currentSession (); Transaction tx = session.beginTransaction (); for (int I = 0; I
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.