Example & Tutorial understanding programming in easy ways.

What are the various fetching strategies from the database in Hibernate?

Fetching Strategies: In the Hibernate we have few fetching strategies to optimize the Hibernate generated select statement, so that it can be as efficient as possible. The fetching strategy is declared in the mapping relationship to define how Hibernate fetch its related collections and entities.


There are four fetching strategies


1. fetch-”join” = Disable the lazy loading, always load all the collections and entities.

2. fetch-”select” (default) = Lazy load all the collections and entities.

3. batch-size=”N” = Fetching up to ‘N’ collections or entities, *Not record*.

4. fetch-”subselect” = Group its collection into a sub select statement.

Read More →