【发布时间】:2016-08-09 02:12:49
【问题描述】:
我有以下 JPA 查询:select NEW java.lang.String(c.country) from Contact c group by c.country order by c.country
当联系人表中的某一行为国家/地区字段保存空值时,上述 JPA 查询中的字符串构造函数将引发 NullPointerException。
由于允许在联系人表中的国家/地区字段中使用空值,是否有任何方法可以通过代码阻止它并仍然使用命名查询?
【问题讨论】:
-
在 WHERE 语句中使用 c.country != null 怎么样?
标签: java jpa constructor