-->
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.  [ 25 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: Criteria eager fetching of collection with alias
PostPosted: Fri Mar 12, 2010 11:57 am 
Newbie

Joined: Fri Mar 12, 2010 11:54 am
Posts: 1
biso,
See http://opensource.atlassian.com/project ... e/HHH-3524, someone posted a workaround by using left joins on createCriteria/createAlias.


Top
 Profile  
 
 Post subject: Re:
PostPosted: Wed Jun 16, 2010 8:42 am 
Regular
Regular

Joined: Sat Nov 19, 2005 2:46 pm
Posts: 69
gavin wrote:
Um. I thought my post was pretty explicit....

It cannot be done and it should not be done and you are trying to do a Bad Thing.

Instead, you should be using setResultTransformer(ALIAS_TO_ENTITY_MAP).



I realize that this post is 5 years old, however it comes up top in google searches for "criteria api eager fetch" and there have been some posts as recent as 2010.

To Gavin:

Your post was indeed explicit, but utterly utterly unhelpful. (And a touch arrogant too.)
Why is it a "Bad Thing"?
What does using ALIAS_TO_ENTITY_MAP do for us in terms of eager fetching, that cannot be done by loading a collection eagerly at query time?

Stewart

_________________
Stewart
London, UK


Top
 Profile  
 
 Post subject: Re: Criteria eager fetching of collection with alias
PostPosted: Thu Jun 17, 2010 4:05 am 
Newbie

Joined: Tue Apr 13, 2010 2:23 am
Posts: 7
This is correct behavior and will certainly not be changed.

_________________
Hobbies Sports: Playing golf!

ping g10 driver*
ping g10 irons|


Top
 Profile  
 
 Post subject: Re: Criteria eager fetching of collection with alias
PostPosted: Thu Jun 17, 2010 4:50 am 
Regular
Regular

Joined: Sat Nov 19, 2005 2:46 pm
Posts: 69
aliaba wrote:
This is correct behavior and will certainly not be changed.


What's that supposed to mean? Are you quoting gavin or attempting to explain somthing?

_________________
Stewart
London, UK


Top
 Profile  
 
 Post subject: Re: Criteria eager fetching of collection with alias
PostPosted: Mon Aug 02, 2010 12:46 am 
Newbie

Joined: Mon Aug 02, 2010 12:32 am
Posts: 1
Thank you for your post Stewart. I registered for this forum just to agree with you.

I don't understand why Gavin would be so consistently rude. It's strange that someone who has dedicated so much of his time to providing community tools would then be so surprisingly unhelpful and condescending to his users on this forum. I have come up to speed with Hibernate over the last year and have been very pleased with it for the most part. But I have also learned to expect nothing but arrogant, unhelpful responses from the "Hibernate Team" on this board.

Gavin, we know you are brilliant. Just imagine that you are teaching kindergarten and need to exercise patience and restraint with your young charges. You don't need to beat them as if they were all eating the paste.


Top
 Profile  
 
 Post subject: Re: Criteria eager fetching of collection with alias
PostPosted: Thu Oct 07, 2010 3:41 pm 
Newbie

Joined: Thu Oct 07, 2010 3:36 pm
Posts: 1
I worked around the same problem using
Code:
criteria.createAlias("kittens", "kittens",Criteria.LEFT_JOIN);
        criteria.setFetchMode("kittens",FetchMode.SELECT);

I don't know if it is a bad thing too
I hope it helps


Top
 Profile  
 
 Post subject: Re: Criteria eager fetching of collection with alias
PostPosted: Fri Sep 09, 2011 9:37 am 
Newbie

Joined: Fri Sep 09, 2011 9:31 am
Posts: 2
yes! Thank you Nora, you are a lovely human being. I've made this account just to thank you for solving a problem that these super-guys from the Hibernate development team have got me confronted with and have no idea how to solve.

And in case anyone is wondering, yep, Gaving King is a prick. He was one 6 years ago and he is one now. I'm sorry Gavin, but your product is crap, and I advocate against it whenever I have the chance. It's buggy as hell, it has horrible stack tracing and debug logging, JPA (and now JPA2) implementations (others than the Hibernate one which is crap as well) are far beter than this garbage. Thank god you've developed your own programming language and you won't pollute the Java environment so much with your crap.


Top
 Profile  
 
 Post subject: Re: Criteria eager fetching of collection with alias
PostPosted: Fri Sep 09, 2011 11:01 am 
Newbie

Joined: Fri Sep 09, 2011 9:31 am
Posts: 2
Sorry (to the other readers) for the previous big red post but i am very pissed. To sum up, for anyone who stumbles up this:


- Nora's solution works, it's ok, do that to get the normal result when doing an alias
- Gavin King's post, that, in fact, the original behaviour is normal, is complete crap and here's why:

I've wasted 1 whole day debugging hibernate, the objects that are returned and the sql issued when you do a criteria.createAlias(associationPath, alias). It issues an inner join. The associated persistence bag is initialized, all the needed values are threre. Yet, when you access somethign on that association it will issue another select to retrieve it, even tho the data is already fetched. In the scenario I'm working now, these n+1 selects ended up in an application response time which was about 2x - 3x time slower then when they were removed. How can issuing an uncontrolled bunch of extra queries to get data that was already fetched be considered normal behaviour


Hibernate has tons of bugs, some of which exists for years now. The jpa implementation is probably the crappiest of them all. There are clear JPA specs and behaviours, that work as expected in Eclipse Link JPA implementation and which simply crash with weird stack traces in Hibernate jpa implementation. This is true of JPA1 and JPA2 implementations. I've stumbled upon tons of these while studying for the JPA exams, while trying the same things with eclipse link and hibernate. Some of them have JIRAs raised, most of them do not. Most of the ones with JIRAs are in "this is not a bug" or "this will not be fixed" statuses.

Sorry readers, but I think it's understandable why I'd get so pissed under such circumstances.

My advice. Use eclipselink JPA2. Not because it's better (it is), but because IT ACTUALLY DOES WHAT IT SAIS IT DOES.


Top
 Profile  
 
 Post subject: Re: Criteria eager fetching of collection with alias
PostPosted: Fri Sep 09, 2011 2:18 pm 
Newbie

Joined: Tue Aug 09, 2011 9:45 am
Posts: 4
javakata wrote:
yes! Thank you Nora, you are a lovely human being. I've made this account just to thank you for solving a problem that these super-guys from the Hibernate development team have got me confronted with and have no idea how to solve.

And in case anyone is wondering, yep, Gaving King is a prick. He was one 6 years ago and he is one now. I'm sorry Gavin, but your product is crap, and I advocate against it whenever I have the chance. It's buggy as hell, it has horrible stack tracing and debug logging, JPA (and now JPA2) implementations (others than the Hibernate one which is crap as well) are far beter than this garbage. Thank god you've developed your own programming language and you won't pollute the Java environment so much with your crap.

LOL, comedy gold.


Top
 Profile  
 
 Post subject: Re:
PostPosted: Thu Nov 17, 2011 12:15 am 
Newbie

Joined: Thu Nov 17, 2011 12:10 am
Posts: 1
gavin wrote:
Um. I thought my post was pretty explicit....

It cannot be done and it should not be done and you are trying to do a Bad Thing.

Instead, you should be using setResultTransformer(ALIAS_TO_ENTITY_MAP).


This works!


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

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.