您的位置:首页 > 产品设计 > UI/UE

aop.AopInvocationException: null return value from advice does not match primitive return type for

2017-03-09 11:23 1066 查看
在用hibernate进行查询的时候,发生了如下异常:

aop.AopInvocationException: null return value from advice does not match primitive return type for

here is the DAO interface:

@Query(value = “SELECT indexed FROM “+ GlobalConsts.INTELLIF_STATIC + “.” +GlobalConsts.T_NAME_OTHER_DETAIL

+” WHERE id = :id”, nativeQuery = true)

int findLast(@Param(“id”)long id);

如果该id在数据库中不存在,就会返回null,报出异常。

这里可以让返回的值变为包装类,它仅仅只会返回null,而不会报异常。

@Query(value = “SELECT indexed FROM “+ GlobalConsts.INTELLIF_STATIC + “.” +GlobalConsts.T_NAME_OTHER_DETAIL

+” WHERE id = :id”, nativeQuery = true)

Integer findLast(@Param(“id”)long id);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐