Hi,
I've noticed that the fetch/join options seem to result in different behaviour when using criteria vs HQL. Consider this:
<many-to-one name="source"
column="sourceId" fetch="join" lazy="false"
not-null="true"/>
If performing an HQL, this will result in the reference being looked up non-lazily. I.e. after the HQL, the collection is populated. However, take away lazy="false" and this is not the case. But the fetch="join" doesn't seem to result in any change in behaviour - I might as well not have included it.
But if a Criteria based query is executed, if fetch="join" is declared then lazy="false" isn't required - the reference has been loaded.
I'm not at a Hibernate guru status and am therefore unable to decide what should form the correct behaviour, but inconsistency certainly doesn't feel right.
At a guess, for Criteria based queries I'd suggest that if lazy="false" was not declared then the default behaviour (lazy loading) should occur regardless of whether fetch="join" was set.
And for HQL queries, it would be nice to see fetch="join" to be implemented when a "from Object" query is executed, as opposed to the non-lazy loaded attributes loaded via what I assume is fetch="select" behaviour.
John
|