我在hql中有这个查询:
SELECT d.code as row1, d.name as row2, d.contractor.name as row3,
case when e is null then 'no emission'
else case when e.zone is null then 'no coverage'
else e.zone.name
end
end
FROM Design d
left join d.emissions e
WHERE (d.code =:codeParam or :codeParam = null)
and (d.contractor =:contracParam or :contracParam = null)
我希望这列出每个设计,即使它没有排放或它没有区域的排放。如果我只这样做:
case when e is null then 'no emission'
else 'emission'
end
每个设计都列出正确,但当我添加第二个案例 - 时,它只会列出带有区域的设计。
我做错了什么?如果您需要更多信息,请告诉我。任何帮助将受到高度赞赏