case ..当在hql中查询时

时间:2014-05-12 10:46:58

标签: java hql

我必须针对该条目检查null
我有个人对象的地址,所以我试着像下面一样抓取它。

select new map(person.id as id,
               case when person.address is not empty 
               then person.address.city end as city) 
from Person person where person.id=:id

case..when是否适用于where子句

但没有错误和结果。

1 个答案:

答案 0 :(得分:0)

试试这个:

select new map(person.id as id,coalesce(person.address,person.address.city )as city) from Person person