Autofetch: specifies association fetches automatically

Autofetch is an extension to Hibernate that automatically specifies fetch/prefetch joins for programs. The idea is that a program using Autofetch specifies all associations as lazy and includes no fetches in queries, while Autofetch transparently modifies loads/gets/queries to include the right fetch/prefetch directives.

How does it work? Autofetch instruments your entities to monitor your program's traversal patterns off of query results. The first time a query is executed all associations are loaded lazily. Thereafter, Autofetch "learns" the right prefetch directives. Autofetch distinguishes between queries in different call stack contexts so it can provide different prefetch directives for a single query depending on the caller.