Hi
In HQL, you can use the syntax
Code:
SELECT new MyJoinEntity(c1.CityId, c1.CityName, c1.ZipCode, c2.CountryName, c3.ContinentName)
FROM City c1, Country c2, Continent c3
WHERE c1.CityCountry = c2.CountryId
AND c2.CountryContinent = c3.ContinentId
MyJoinEntity class is a "view" and I don't need a hibernate mapping file
I use <import class="MyLibrary.MyJoinEntity"/>
I don't need (and don't want) to describe the join conditions in hbm file
MyJoinEntity class has a constructor with the same signature as the HQL query
Code:
public MyJoinEntity(int cityId, string cityName, string zipCode, string countryName, string continentName)
{
this.CityId = cityId;
this.CityName = cityName;
this.ZipCode = zipCode;
this.CountryName = countryName;
this.ContinentName = continentName;
}
I can get a list of MyJoinEntity
Code:
IList<MyJoinEntity> lst = query.List<MyJoinEntity>();
But sometimes in the database, City.CityCountry is null
I tried to use a
LEFT OUTER JOIN but can't find the correct syntax ang get an error
outer or full join must be followed by path expression
In SQL, you have to use
ON c1.CityCountry = c2.CountryId, but how in HQL ?
Thanks for help