I am using hibernate 3 and I am trying to get the following behavior with batch fetching.
My classes:
I have an object graph where :
Object A has Set of Object B
Object B has Set of Object C
I have batch-size set to 20 for all 3 classes of object A,B,C. And I have not set lazy on the class - so, by default it should be true.
Now within my session, I do a get for object A, then I do a A.getBs to initialize the collection B for A. But, now I want to iterate through the objects in collection B and lazy initialilze ONLY some of them for Collection C based on property value on object B. Is this possible?
What I am seeing the behavior is even though I iterate through the Collection B and do B.getCs only for some of the Bs, it initializes ALL of the Bs with collection C. When I turned on debug for hibernate, I see that the batch loading is happening and a prepare statement is created with obids of ALL Bs for
DEBUG Loader:1456 - batch loading collection: [B.ClassC#<15402, 15439, 15443, 15447, 15451, 15455, 15510, 15684, 15688, 15692, 15415, 15419, 15423, 15427, 15431, 15435>]
DEBUG AbstractBatcher:290 - about to open PreparedStatement (open PreparedStatements: 0, globally: 1)
DEBUG AbstractBatcher:324 - select ClassC ......
|