javax.persistence.NoResultException: getSingleResult() did not retrieve any entities

后端 未结 8 2554
执笔经年
执笔经年 2020-12-14 09:33

i have created a namedquery with ejb to check if the username is used. When the singleResult is null, then i get the following Exception :

javax.persistence.         


        
8条回答
  •  -上瘾入骨i
    2020-12-14 09:52

    If your application uses Spring Roo the most voted answer doesn't work: the exception is caught by the aspects and you never get the desired NoResultException. The only way to solve the issue is to use getResultList and to check for zero, one or more results in the resulting List, as stated in the second most voted answer.

提交回复
热议问题