-->
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.  [ 4 posts ] 
Author Message
 Post subject: How to make outer join with inversed associations
PostPosted: Tue Feb 12, 2013 11:18 am 
Newbie

Joined: Tue Feb 12, 2013 11:05 am
Posts: 2
Hi,

here is an example in pseudo Java :

class Person {
long id
String name
Title title
}

class Title {
long id
}

class TitleTransco {
Title title
long transco
}

I wanna get persons with the transco of their title in 1 request, with an outer join because title may be null.

How to make outer joins in HQL with associations which are "inversed", here between Title and TranscoTitle ?

Note that joining in the where condition is not able to be "outer", only inner.
Note that other similar associations than title are concerned, there are multiple outer join to perform, so starting from to join Title then Person is not a solution either.

Thank you for any answers or ideas to acheive the goal (getting transcoded info).

Dominique.

Note: i'd like not to implement title -> transco because it's usefull for only 1 use case over all and useless for the rest; i'd like to avoid polluting the model.


Top
 Profile  
 
 Post subject: Re: How to make outer join with inversed associations
PostPosted: Wed Feb 13, 2013 4:16 am 
Beginner
Beginner

Joined: Wed Feb 06, 2013 2:43 am
Posts: 46
select pe.name ,tt.transco from Person pe
left outer join TitleTransco tt on pe.title.id = tt.title.id

I am taking this statement as the base.
I wanna get persons with the transco of their title in 1 request, with an outer join because title may be null.

Hope i have answered your question.

_________________
Thanks,
Ajit Singh
ajits@mindfiresolutions.com
www.mindfiresolutions.com


Top
 Profile  
 
 Post subject: Re: How to make outer join with inversed associations
PostPosted: Wed Feb 13, 2013 7:00 am 
Newbie

Joined: Tue Feb 12, 2013 11:05 am
Posts: 2
Ajit,

the instruction "join .. on property = property" is not valid in HQL / Hibernate 3.6; am i wrong ? or were you thinking at a superior version of hibernate ?

Thank you for your contribution

D


Top
 Profile  
 
 Post subject: Re: How to make outer join with inversed associations
PostPosted: Thu Feb 14, 2013 5:25 am 
Beginner
Beginner

Joined: Wed Feb 06, 2013 2:43 am
Posts: 46
Correct .property on property is not allowed. I mixed sql. Sorry about that.

But there is a till a workaround left.

In hibernate every join works on how you map.
So take an inverse mapping in the title class for
ex:
class Title {
long id
TitleTransco transco
}

And then your hibernate query would be :
select p from Person p
left join p.title as t
left join t.transco

I have looked and found this is the only way out.
Now the question is how to add this TitleTransco in your Title class ? toughest part.

Can i have your code for these classes mapping so that i can try it on my end.Give me the annotation classes or the XML files for these, so that i can try.

I am not sure about this path, just making a guess here.

If this doesn't work you have just sql option left for you. :)

_________________
Thanks,
Ajit Singh
ajits@mindfiresolutions.com
www.mindfiresolutions.com


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