[b]Hibernate version: 2.1.7
I have defined a relationship between a "Batch" object and a collection of "Batch Records" with lazy loading turned off i.e. lazy="false". In most cases, when I retrieve a Batch, I want to retrieve all the Batch Records associated with that Batch so having turned off is working out good.
There is however one case where I want to tweak the performance and NOT retrieve all the Batch Records associated with a Batch. I tried to change the FetchMode at runtime using e.g. criteria.setFetchMode("batchRecords", FetchMode.LAZY). This still seems to retrieve all the Batch Records associated with a batch however. Am I missing something?
I see in Hibernate version 3 that FetchMode.LAZY and FetchMode.EAGER have been deprecated. Is this because you can't control 'what' is lazy loaded at runtime, but only 'how' it is retrieved i.e. by changing the status of the outer-join flag at runtime.
Finally, is the recommended approach to set lazy="true" if there is even just a single case where you dont want to load the associated collections of a Batch - and then change the fetch mode to EAGER or (JOIN) at run time?
Thanks
|