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();]]> -