情况:KAM中有一个department,department有多个IATA ,如果要按照KAM的Name或者department的Name来查,则很简单
from KAM as kam where kam.Name="**" and kam.Department.Name="***"
但是如果是按照IATA的名字呢?
from KAM as kam where kam.Name="**" and kam.Department.Name="***" and kam.Depatment.IATAList.IATACode="***"
上面显然不行,因为kam.Depatment.IATAList是个集合,没有Name属性
后来查到这里可以这么写
select distinct kam from KAMVO as kam inner join kam.Department.IATAList as iATA where kam.name="***" and
iATA.IATACode="****"
可以参照MANAGER/KAM/COND/KAMCOND.cs
注:采用INNER JOIN 实属无奈,貌似HQL里面ORACLE方言不支持RIGHT JOIN。好在后面还要SELECT一下,就在后面加了 distinct