I have two tables
city
region
and 4 classes
City
SpecialCity extends City
Region
SpecialRegion extends Region
Some cities have regions, others do not. Some cities belong to SpecialRegions others just to Regions
I want to get all SpecialCities and Cities that belong to a SpecialRegion.
Using Criteria I quickly ran into trouble so I went with hql.
The query I'm looking for is something like
Code:
select city0_.*, region1_.* from City city0_
left outer join Region region1_ on city0_.FK_regionID=region1_.regionId
where city0_.FK_CountryID=2
and (region1_.DTYPE='SPL' or city0_.DTYPE='SPL')
When I use the following hql I would expect to get the above
Code:
from City c left outer join c.region where c.country = ? and (c.region.class = SpecialRegion or c.class = SpecialCity)
However, I get this, resulting in effectively an inner join between region and city
Code:
select city0_.*, region1_.* from City city0_
left outer join Region region1_ on city0_.FK_regionID=region1_.regionId
cross join Region region2_
where city0_.FK_regionID=region2_.regionId
and city0_.FK_CountryID=2
and (region2_.DTYPE='SPL' or city0_.DTYPE='SPL')
Is this a mistake on my side? If so, how can I fix this?
Kind regards,
Marc