Can javax.persistence.Query.getResultList() return null?

You are right. JPA specification says nothing about it. But Java Persistence with Hibernate book, 2nd edition, says:

If the query result is empty, a null is returned

Hibernate JPA implementation (Entity Manager) return null when you call query.getResultList() with no result.

UPDATE

As pointed out by some users, it seems that a newest version of Hibernate returns an empty list instead.

An empty list is returned in Eclipselink as well when no results are found.

Leave a Comment