Irrespective of version of hibernate, I have this question on hibernate efficiency in 1-many OR mapping situations.
I have a situation where I have tables T1, T2, T3, T4, T5
T1 has 1-many relationship with T2
T2 has 1-many relationship with T3
T3 has 1-many relationship with T4
T4 has 1-many relationship with T5
I guess u got the picture!
Now I have classes C1, C2, C3, C4, C5 representing the corresponding tables and each 1-many uses with Set data type.
But, my problem is my business case only wants information about C1, and corresponding C5. So, hibernate loads all the entities belonging all 5 classes (tables) into memory (ofcourse hibernate has to navigate the tree path) so I can retrieve data for C1 and C5. Obviously if you use plain JDBC, you can write the same query but just what you want (C1 and C5 fields), which I think lot more efficient especially when database and app server are in different servers on the network.
is there any better way of mapping in this kind of relationships and business cases?
Thanks
R
|