Fetch groups are updated using methods on this interface. An instance of a class implementing this interface can be obtained from {@link PersistenceManager#getFetchGroup} or{@link PersistenceManagerFactory#getFetchGroup}.
A FetchGroup can be unscoped or can be in one of two scopes (the {@link PersistenceManager} or the {@link PersistenceManagerFactory} scope). Unscoped FetchGroups do not affect any behavior. A FetchGroup in PersistenceManager scope hides the corresponding FetchGroup in the PersistenceManagerFactory scope.
PersistenceManager
. Subsequent modifications of the FetchGroup immediately affect FetchPlan
s that contain the FetchGroup
. PersistenceManagerFactory
. Purpose: A fetch group is a performance enhancement that allows a group of attributes of an object to be loaded on demand, which means that the data for an attribute might not loaded from the underlying data source until an explicit access call for the attribute first occurs. It avoids the wasteful practice of loading up all data of the object?s attributes, in which the user is interested in only partial of them. A great deal of caution and careful system use case analysis should be use when using the fetch group feature, as the extra round-trip would well offset the gain from the deferred loading in many cases. TopLink fetch group support is twofold: the pre-defined fetch groups at the descriptor level; and dynamic (use case) fetch groups at the query level. TopLink fetch group support is only on CMP project. Every query can has at most one fetch group. There is an optional pre-defined default fetch group at the descriptor level. If set, and the query has no fetch group being set, the default fetch group would be used, unless query.setShouldUseDefaultFetchGroup(false) is also called. In the latter case, the full object will be fetched after the query execution. @see oracle.toplink.essentials.queryframework.FetchGroup @see oracle.toplink.essentials.queryframework.FetchGroupTracker @author King Wang @since TopLink 10.1.3.
FetchGroup usage is only possible when an entity class implements the {@link FetchGroupTracker} interface so that the FetchGroup can be stored inthe entity. The entity must also use the provided check methods to ensure the attributes are loaded prior to use. In general this support is enabled through weaving of the entity classes. If an entity class does not implement {@link FetchGroupTracker} no FetchGroup functionality will be supported andattempted use of a FetchGroup in a query will not result in the expected behavior.
FetchGroups are defined in 3 ways:
When a query is executed only one FetchGroup will be used. The order of precedence is:
Loading: A FetchGroup can optionally specify that it needs its included relationships loaded. This can be done using {@link #setShouldLoad(boolean)} and {@link #setShouldLoadAll(boolean)} aswell as the corresponding configurations in the @FetchGroup annotation and the
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|