one to one(join column in right place) causes HQL eager fetch failure

Description

See the end of this post...

The test case and all code can be found in here....(just modified the Cat->Kitten example till it broke)....
https://forum.hibernate.org/viewtopic.php?f=1&t=1002721&p=2425506#p2425506

basic summary though is if you have
SELECT s FROM Cat s inner join fetch s.kitten

and you redefine Cat->Kitten to be OneToOne, it works great if JoinColumn is on kitten, but if you move JoinColumn to Cat, it results in a 1+N select where the first sql got all the data needed by hibernate to fill in the Cats and their kitten. We have a 100 page result set that is doing 1+N selects here.

ie. if you leave the join column on kitten, the following sql is 1+N then....
SELECT k FROM Kitten k inner join fetch k.cat; (ie. a more likely case since there may be Cats without kitten, but a kitten always have a cat...that is the situation we have in our object model).

so onetoone eager fetch joins only work on half the cases out there from what I can tell and you get lucky if your join column is on the right object.

Activity

Show:

Brett Meyer July 8, 2014 at 3:10 PM

Bulk rejecting stale issues. If this is still a legitimate issue on ORM 4, feel free to comment and attach a test case. I'll address responses case-by-case. Thanks!

Brett Meyer April 7, 2014 at 5:41 PM

In an effort to clean up, in bulk, tickets that are most likely out of date, we're transitioning all ORM 3 tickets to an "Awaiting Test Case" state. Please see http://in.relation.to/Bloggers/HibernateORMJIRAPoliciesAndCleanUpTactics for more information.

If this is still a legitimate bug in ORM 4, please provide either a test case that reproduces it or enough detail (entities, mappings, snippets, etc.) to show that it still fails on 4. If nothing is received within 3 months or so, we'll be automatically closing them.

Thank you!

Dean Hiller February 18, 2010 at 7:23 PM

YES YES YES, I just found a workaround(thank god). Use ManyToOne and OneToMany and it now goes back to a single select!!!!

yeahhhhhhhh

Rejected

Details

Assignee

Reporter

Affects versions

Priority

Created February 18, 2010 at 6:17 PM
Updated July 8, 2014 at 3:10 PM
Resolved July 8, 2014 at 3:10 PM