Hibernate version: 2.1.6
Name and version of the database you are using: Microsoft SQL Server 2000
I have the following object graph:
Class A contains a one-to-many relationship with class B (with a size ranging from 5 to 5000 objects)
Class B contains a one-to-many relationship with class C (with a size of around 7 objects)
Class C contains a one-to-many relationship with class D (some of size 0 object and some of size 5 objects)
When I load Class A’s collection of B objects, I need to load the full object graph (Class B’s collection of C objects, and Class C’s collection of D objects). I am currently setting a large batch-size value on these collections to decrease the number of queries that need to be run to load the object graph. However, for my large A objects (when A has 5000 B objects), there are still to many queries being run to load all of my D objects.
I’d like to set it up so that C’s collection of D objects are loaded through an outer join when the collection of C objects is loaded. Then, the following queries would be executed:
1. Load all B objects that are a member of A
2. For each batch of B objects in A, load all C & D objects that are in a B in this batch
Is there anyway to configure this? Also, is there anyway to dynamically select batch-size? I know this will eliminate the benefit of prepared statements, but the benefit may outweigh that cost for me.
Or, are there any other alternatives that may help me?
Thanks in advance for any help.
|