venerdì 25 novembre 2011

Exception thrown by Query.getSingleResult() on empty resultset

When I ran a query (javax.persistence.Query) to check the existence of a record I got:

22:06:12,026 ERROR [org.jboss.ejb3.tx2.impl.CMTTxInterceptor] javax.ejb.EJBTransactionRolledbackException: No entity found for query

As described in this thread getSigleResult() if there isn't any record to fetch throws a NoResultException.
Use instead getResultList() 

Nessun commento:

Posta un commento