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 ?
|