Monday, January 30, 2012

Hibernate Fetching Statergies

1. Batch Fetching. Defined batch-size in hibernate xml for the collection, would fetch the items in a single query. Create the proxies.
2. Subselects. Fetch="subselect" would create a sub query for getting the child elements.
3. Joins. Fetch="Joins" would disable lazy loading and create a single query with joining the child table. If we just define lazy = false or Fetch = eager, it would execute two queries first for parent and second for child. Hibernate executes outer joins. If we write , hibernate would execute inner join.