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

    xiaoxiao2021-03-25  158

    在用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);

    转载请注明原文地址: https://ju.6miu.com/read-10144.html

    最新回复(0)