-->
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.  [ 8 posts ] 
Author Message
 Post subject: <key-many-to-one> outer joins?
PostPosted: Wed Dec 03, 2003 10:43 pm 
Regular
Regular

Joined: Tue Nov 11, 2003 7:35 pm
Posts: 63
Is it possible to specify an outer join for a <key-many-to-one> relationship?

Specifically, I have a persistant object A with a composite key. One of the elemets of those keys is an associated key-many-to-one assiciation with class B (I hope I have the terminology correct). I would like that when I load class A, class B would be loaded in an outer join. This is especially useful when class A itself is part of a collection loaded by yet another class C.

So I have:

C has a Set of A objects
A is associated with B

I would like that when I get the collection of A, the associated B objects would be outer joined while loading. Otherwise I would need to make a new db call for each element of A while iterating, which is obviously inefficent.

If outer joins are not possible with <key-many-to-one> associated classes, is there perhaps another way to do everything in one SQL call? I guess handcoding a query is one way, but is there some other "automatic" way?

Please let me know if you need any more specifics.

Thanks in advance,
Daniel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 04, 2003 2:49 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
No, it is not possible.

My preferred alternative is to *not* use a <key-many-to-one>, but instead use a <key-property>, together with an ordinary <many-to-one> mapped with insert="false" update="false".

I hope to support outer-join fetching and criteria query joins for <key-many-to-one> in Hibernate 2.2 (or perhaps 2.1.x).


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 04, 2003 10:30 am 
Regular
Regular

Joined: Tue Nov 11, 2003 7:35 pm
Posts: 63
ok.

Note though that my key-one-to-many mapping was generated by Middlegen. Perhaps the template for middlegen should be changed as well to use the alternative mapping you described. (But I guess it is not essential, since as you said outer join fetching will eventually be supported for this kind of mapping as well. In the meantime I may change the template for my own app.)

Thanks,
Daniel


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 13, 2004 2:21 pm 
Expert
Expert

Joined: Sat Jan 17, 2004 2:57 pm
Posts: 329
Location: In the basement in my underwear
Gavin,

Is there any update on the status of this? I was previously told to RTFM from another developer when I inquired about doing a join query using a key many to one and Criteria. Just wondering if this is:
a)Implemented already (if so, what version)
b)Planned for implementation at some later date
c)Not planned for implementation at all


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 13, 2004 4:05 pm 
Expert
Expert

Joined: Sat Jan 17, 2004 2:57 pm
Posts: 329
Location: In the basement in my underwear
As a followup, if I don't use a key many to one does this not break bidirectionality?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 13, 2004 9:28 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
(b)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 13, 2004 9:59 pm 
Expert
Expert

Joined: Sat Jan 17, 2004 2:57 pm
Posts: 329
Location: In the basement in my underwear
Thanks for the reply Gavin.

We've gone with a dual many to one for now. (A key many to one and then a many to one mapped with insert/update=false.) We're probably going to take a performance hit (if it even works :)) but my view is that we'd rather not have to jack around trying to get everything synced back up.

Is there any type of documented road map for the Criteria API?

In particular I am interested if Outer Joins would ever be supported. You mentioned back in Dec of last year that it would be trivial but didn't want to implement due to keeping it simple.

The other thing I am interested in is the having mapping two aliases to the same table via Criteria API. It looks like it doesn't work now due to the fact that the association paths are stored in HashMaps internal to the CriteriaImpl so the last one in wins.

I never thought in a million years that I would ever have to write a query like that but alas the time has come :( Actually, I'm still not sure if there's not another way around it.

I think the Criteria API is fantastic and allows us to build a framework to handle dynamic queries with ease. Much better than having to use String manipulation in order to build dynamic HQL (which is what the Criteria API is already doing well for 99% of the cases for us).

Thanks for the work you guys put out. Now if only we could fix our datamodel :)


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 31, 2005 8:28 am 
Regular
Regular

Joined: Wed Sep 22, 2004 8:27 am
Posts: 89
now we are at 3.05 release, but i've yet the problem, any solution for join or only property with update=insert=false?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 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.