View RSS Feed

My Java Tips

Hibernate - Fetching strategies

Rate this Entry
by , 10-25-2011 at 06:49 PM (1269 Views)
Hibernate 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.

Submit "Hibernate - Fetching strategies" to Facebook Submit "Hibernate - Fetching strategies" to Digg Submit "Hibernate - Fetching strategies" to del.icio.us Submit "Hibernate - Fetching strategies" to StumbleUpon Submit "Hibernate - Fetching strategies" to Google

Categories
Hibernate

Comments