Hibernate - Fetching strategies
30 August 2008Hibernate uses fetching strategy for retrieving associated objects when an application needs to navigate the association. Fetch strategies are declared in the object relational mapping metadata, or over-ridden by a particular HQL or Criteria query.
Hibernate defines following fetching strategies:
- Join fetching is used to retrieve the associated instance or collection in the same SELECT, using an OUTER JOIN.
- Select fetching is used to retrieve the associated entity or collection. Unless you explicitly disable lazy fetching by specifying lazy=”false”, this second select will only be executed when you actually access the association.
- Subselect fetching is used to retrieve the associated collections for all entities retrieved in a previous query or fetch. Unless you explicitly disable lazy fetching by specifying lazy=”false”, this second select will only be executed when you actually access the association.
- Batch fetching is an optimization strategy for select fetching. It retrieves a batch of entity instances or collections in a single SELECT, by specifying a list of primary keys or foreign keys.
Related Posts:
Top Of Page | Trackback
If you found this page useful, consider linking to it. Simply copy and paste the code below into your web site.
It will look like this: Hibernate - Fetching strategies