I quote Hibernate doc :
Quote:
A fetch join does not usually need to assign an alias, because the associated objects should not be used in the where clause (or any other clause)
Nevertheless, I find the use of where+fetch really usefull for plenty of use cases !
But I may be misusing it...
My use case :
T1-->(*)T2-->(*)T3
I want to retreive one specific T3, with all its parents (All my relations must be lazy='true', and I can not use lazy fetching).
This works :
Code:
from T1 t1 left join fetch t1.t2s t2 left join fetch t2.t3s t3 where t3.name='MyT3'
I get one T1, linked to one T2, linked to one T3 (one SQL request!)
Why should I try to avoid this way of doing ? Is there a better way to achieve the same result ?
A simple join should do it, but I won't get an object tree... And I want all objects to be linked, it is easier for the layer that uses the data.
Thanks !