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.
Use getResultList instead and check if the List is empty (has zero element). Otherwise, the list contains one element and you simply return it.
getResultList
List