From 9b8b82b5492a7cf1962b740770efb23953fb4582 Mon Sep 17 00:00:00 2001 From: Steve Ebersole Date: Wed, 4 Nov 2009 22:28:47 +0000 Subject: [PATCH] HHH-4006 - Document fetch profiles git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@17915 1b8cb986-b30d-0410-93ca-fae66ebed9b2 --- .../docbook/en-US/content/performance.xml | 72 ++++++++++++++++++- 1 file changed, 70 insertions(+), 2 deletions(-) diff --git a/documentation/manual/src/main/docbook/en-US/content/performance.xml b/documentation/manual/src/main/docbook/en-US/content/performance.xml index 09d63f866a..d8d4c8c55e 100644 --- a/documentation/manual/src/main/docbook/en-US/content/performance.xml +++ b/documentation/manual/src/main/docbook/en-US/content/performance.xml @@ -589,7 +589,76 @@ Cat fritz = (Cat) iter.next();]]> - + + + Fetch profiles + + + Another way to affect the fetching strategy for loading associated objects is through something + called a fetch profile, which is a named configuration associated with the + org.hibernate.SessionFactory but enabled, by name, on the + org.hibernate.Session. Once enabled on a + org.hibernate.Session, the fetch profile wull be in affect for + that org.hibernate.Session until it is explicitly disabled. + + + So what does that mean? Well lets explain that by way of an example. Say we have + the following mappings: + + + + ... + + + + + + + ... + +]]> + + Now normally when you get a reference to a particular customer, that customer's set of + orders will be lazy meaning we will not yet have loaded those orders from the database. + Normally this is a good thing. Now lets say that you have a certain use case where + it is more efficient to load the customer and their orders together. One way certainly is + to use "dynamic fetching" strategies via an HQL or criteria queries. But another option is + to use a fetch profile to achieve that. Just add the following to your mapping: + + + ... + + + +]]> + + or even: + + + + ... + + + + + ... +]]> + + Now the following code will actually load both the customer and their orders: + + + + Currently only join style fetch profiles are supported, but they plan is to support additional + styles. See HHH-3414 + for details. + + + Using lazy property fetching @@ -653,7 +722,6 @@ Cat fritz = (Cat) iter.next();]]> -