Hibernate version: 2.1.8
Hi everybody! Here is the problem:
I have 5 tables and 5 classes: X, Y, I, G.
They are mapped with "one-to-many" as following:
X --one-to-many--> Y
I --one-to-many--> Y
I --one-to-many--> G
As you can see, there are 2 classes which are pointing to class Y.
In my program, i am loading class Y.
Loading of this class, should cause classes X and I to be loaded.
Now suppose that there is no data in table I, and the field in Y that points on I contains null. In that case there won't be any functional impact, because hibernate will generate OUTER-JOINS.
Those outer-joins will include joins:
1. from Y to X
2. from Y to I
3. from I to G
The problem is: because there is no data in table I, join #2 will retrieve no data, and join #3 will perform FULL TABLE SCAN.
My question is:
How to pervent this from happening?
Why does hibernate generate joins #2 and #3 despite there is null value in the relevant field in class Y?
Thanks a lot!
Michael.
|