-->
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.  [ 1 post ] 
Author Message
 Post subject: Outer Join Referencing Same Table Twice
PostPosted: Fri Jun 03, 2005 5:45 pm 
Newbie

Joined: Fri Jun 03, 2005 5:34 pm
Posts: 1
I am performing a Criteria query using hibernate 3.0.5

I have three tables: AGENT, RISK and RISKAGENTXREF.

class Agent {
Set riskagentxrefs; //inverse="true"
...
}

class Risk {
Set riskagentxrefs; //inverse="true"
...
}

class Riskagentxref {
Agent agent;
Risk risk;
...
}


I am querying for a list of Agents. I have set the fetch mode for the riskagentxrefs collection in the Agent class to FetchMode.OUTER_JOIN.

Everything works as advertised, but the generated sql outer joins
Agent to Riskagentxref to Agent.

It seems like this third join is unnecessary as Agent has already been included. This adds performance overhead for no reason.

Is this possibly a bug, or is there some way for me to tell hibernate not to join the same table twice.

Thank you for any help you may provide.

I have included the sql code for the query:

select * from ( select rownumber() over(order by this_.AGTNAM asc) as rownumber_, this_.AGTNUM as AGTNUM2_, this_.AGTID as AGTID0_2_, this_.AGTSUF as AGTSUF0_2_, this_.AGTNAM as AGTNAM0_2_, this_.AGTSTR as AGTSTR0_2_, this_.AGTS#2 as AGTS6_0_2_, this_.AGTCTY as AGTCTY0_2_, this_.AGTSTA as AGTSTA0_2_, this_.AGTZP5 as AGTZP9_0_2_, this_.AGTZP4 as AGTZP10_0_2_, this_.AGTTID as AGTTID0_2_, this_.AGTTX# as AGTTX12_0_2_, riskagentx2_.AGTNUM as AGTNUM4_, riskagentx2_.ID as ID4_, riskagentx2_.ID as ID0_, riskagentx2_.MAJRSK as MAJRSK3_0_, riskagentx2_.AGGBEG as AGGBEG3_0_, riskagentx2_.AGTNUM as AGTNUM3_0_, agent3_.AGTNUM as AGTNUM1_, agent3_.AGTID as AGTID0_1_, agent3_.AGTSUF as AGTSUF0_1_, agent3_.AGTNAM as AGTNAM0_1_, agent3_.AGTSTR as AGTSTR0_1_, agent3_.AGTS#2 as AGTS6_0_1_, agent3_.AGTCTY as AGTCTY0_1_, agent3_.AGTSTA as AGTSTA0_1_, agent3_.AGTZP5 as AGTZP9_0_1_, agent3_.AGTZP4 as AGTZP10_0_1_, agent3_.AGTTID as AGTTID0_1_, agent3_.AGTTX# as AGTTX12_0_1_ from GRAYDATA.AGENTSP this_ left outer join USERS.RISKAGENTXREFP riskagentx2_ on this_.AGTNUM=riskagentx2_.AGTNUM left outer join GRAYDATA.AGENTSP agent3_ on riskagentx2_.AGTNUM=agent3_.AGTNUM order by this_.AGTNAM asc ) as temp_ where rownumber_ between ?+1 and ?


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

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.