In our application, where we are using 'org.hibernate.Criteria' to fetch records.
Here is a brief description of the object relationships:
1) A is the parent object
2) B, C, D are children of A
3) E is child of B
For A.C, the 'FetchMode.JOIN' is specified.
For A.B and A.D, the 'FetchMode.SELECT' is specified.
For B.E, the 'FetchMode.SELECT' is specified.
Scenario 1:
The count of instances for A is 1. i.e. in the IN clause of the SQL to load A, only one value is passed.
250 Bs and Ds exist for that A. And 250 Es exist with 1-to-1 multiplicity with B.
Here we observed that only one SQL is being fired per entity (A join with C, B, D, E)
Scenario 2 (The problem case):
The count of instances for A is 60. i.e. in the IN clause of the SQL to load A, 60 values are passed.
60 Bs and Ds exist with 1-to-1 multiplicity with A. And 250 Es exist with 1-to-1 multiplicity with B.
Here we observed that only one SQL is being fired for A join with C.
But 4 SQLs were being fired for B, D and E.
There was a consistent pattern of the first SQL having 31 values in the IN clause , the second having 15 , third having 10 and the last having 4.
We have 'hibernate.jdbc.fetch_size' as 200 in the hibernate.cfg.xml and the batch-size is set as 250
for all A, B, C, D and E.
The hibernate version is 3.1.1 and Database used is Oracle 9.2.0.6.0.
Can anyone help us in identifying why the query is split up in the second scenario?
|