I have a fairly simple HQL Query
Code:
SELECT
DISTINCT SUM(tbl.fees.price),
country.region.regionName
FROM Account tbl
WHERE tbl.fees.price > :fees_price
GROUP BY country.region.regionName
And it almost
works, the only problem with it is that it joins the
fees table twice in the SQL.
Code:
select distinct SUM(fees1_.price) as col_0_0_, region3_.regionName as col_1_0_ from Account account0_, AccountFee fees1_, Country country2_, Region region3_, AccountFee fees4_ where account0_.id=fees4_.account_id and country2_.region_id=region3_.id and account0_.country_id=country2_.id and account0_.id=fees1_.account_id and fees4_.price>? group by region3_.regionName
Notice the fees4_.prrice > ? in the where clause. I really want that to be just fees1_.price instead. What do I need to add to get this to work correctly? I really don't need the extra join in there at all and would like it to just go away if possible.
Thanks for the help!
-Nick