-->
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.  [ 2 posts ] 
Author Message
 Post subject: FetchMode.JOIN breaks when ordering
PostPosted: Wed Jan 04, 2006 10:52 am 
Beginner
Beginner

Joined: Wed Sep 14, 2005 9:11 am
Posts: 22
This works fine:
...
crit.setFetchMode("phones", FetchMode.JOIN);
...
// sometime later - session is now closed
// and contact has been populated from the query
contact.getPhones();

This does not work:
...
crit.setFetchMode("phones", FetchMode.JOIN);
crit.createAlias("phones", "ps");
crit.addOrder(Order.asc("ps.areaCode"));
...
// sometime later - session is now closed
// and contact has been populated from the query.
// Throws LazyInitializationException
contact.getPhones();

I also tried this:
...
crit.setFetchMode("phones", FetchMode.JOIN);
Criteria crit2 = crit.createCriteria("phones");
crit2.addOrder(Order.asc("areaCode"));
...
// sometime later - session is now closed
// and contact has been populated from the query.
// also throws LazyInitializationException
contact.getPhones();

Any idea how to get around this?
Thanks,
Ben


Top
 Profile  
 
 Post subject: Known issue
PostPosted: Thu Jan 05, 2006 5:20 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
This is a known issue. Check out JIRA HHH-997 (Gavin says "it's a known issue", marks it as a duplicate... but doesn't list the duplicate?) and HHH-1162. HHH-1162 is more useful: essentially, the createAlias part forces an inner join, overriding the setFetchMode's outer join preference.

To resolve in the short term, remove the alias and work with the long notation. Watch HHH-1162 to see when it gets resolved.


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

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.