-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Fetch/join HQL/Criteria inconsistencies
PostPosted: Wed Dec 19, 2007 8:30 am 
Newbie

Joined: Wed Dec 19, 2007 7:10 am
Posts: 10
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.