as described in JPA:
{code:java} /** * Execute a SELECT query that returns a single untyped result. * @return the result * @throws NoResultException if there is no result * @throws NonUniqueResultException if more than one result * @throws IllegalStateException if called for a Java * Persistence query language UPDATE or DELETE statement * @throws QueryTimeoutException if the query execution exceeds * the query timeout value set and only the statement is * rolled back * @throws TransactionRequiredException if a lock mode other than * <code>NONE</code> has been set and there is no transaction * or the persistence context has not been joined to the transaction * @throws PessimisticLockException if pessimistic locking * fails and the transaction is rolled back * @throws LockTimeoutException if pessimistic locking * fails and only the statement is rolled back * @throws PersistenceException if the query execution exceeds * the query timeout value set and the transaction * is rolled back */ Object getSingleResult(); {code}
getSingleResult should throw NoResultException, but in Hibernate 5.2 it does not thrown, and returns null instead. my code is: {code:java} entityManager.createNamedQuery("some query") .getSingleResult() {code}
|
|