In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Xiaobian to share with you what Hibernate use batch grab skills, I believe most people do not know how, so share this article for everyone's reference, I hope you have a lot of harvest after reading this article, let's go to understand it together!
Hibernate bulk fetching is an optimization scheme for deferred query fetching, and you can choose between two Hibernate bulk fetching schemes: at the class level and at the collection level.
Batch fetching at the class/entity level is easy to understand. Suppose at runtime that you are faced with the following problem: You load 25 Cat instances in a Session, each Cat instance has a reference member owner pointing to Person, and the Person class is a delegate, with lazy="true".
If you have to traverse the entire collection of cats, calling getOwner() on each element, Hibernate will default to 25 SELECT queries to get its owner proxy object. At this point, you can change its behavior by explicitly declaring batch-size in the Person attribute of the mapping file:
...
Hibernate will then need to execute only three queries, 10, 10, and 5.
You can also define bulk fetching at the collection level. For example, if each Person has a collection of late-loaded Cats, and Sesssion now has 10 person objects loaded, traversing the person collection will result in 10 SELECT queries, each of which calls the getCats() method. If you allow bulk fetching of cats in the mapping definition section of Person, Hibernate will be able to pre-fetch the entire collection.
Please see examples:
...
If the overall batch-size is 3 (typo?), Hibernate will then execute the SELECT query four times, loading the data in sizes 3, 3, 3, and 1. The amount of data loaded at a time also depends on the number of uninstantiated collections in the current Session.
Hibernate batch fetching of collections is useful if your model has nested tree structures, such as the typical bill-of-materials pattern. (Although nested sets or materialized paths (××) are better solutions when reading trees more often.)
The above is "Hibernate use bulk grab skills what" all the content of this article, thank you for reading! I believe that everyone has a certain understanding, hope to share the content to help everyone, if you still want to learn more knowledge, welcome to pay attention to 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.