java如何防止包含字符串构造函数的JPA查询在空字符串值仅可用时引发NullPointerException
我有以下JPA查询:选择新java。lang.String(c.country)按c.country从联系人c组按c.country排序按c.country排序
当Contact表中的一行为country字段保留空值时,上面JPA查询中的字符串构造函数会抛出NullPointerException
由于联系人表中的country字段允许空值,有没有办法通过代码阻止它,并且仍然使用命名查询
# 1 楼答案
那怎么办