Replies: 3 comments
-
This is simply false. Hibernate always returns an empty list when a query returns no results. And this has been the case since before Hibernate 1.0. No version of Hibernate has ever used (I suppose it's possible that you once ran into a bug in some very specific exceptional case.)
The expectation has always been that So we could certainly make this more explicit, but FWIW I think it's always been pretty clear that an empty list is the correct way to represent "no results". Because using null for this would be obviously insane. |
Beta Was this translation helpful? Give feedback.
-
See proposed change here: https://github.com/jakartaee/persistence/pull/538/files |
Beta Was this translation helpful? Give feedback.
-
Thank your for your response and your PR! |
Beta Was this translation helpful? Give feedback.
-
Hey everyone,
this is my first time to get in closer contact with the Jakarta Team and as I can't imagine that this topic was never discussed before and I couldn't find an (open or closed) issue/discussion/etc I decided to ask this question/idea here:
The Javadoc of the persistence spec of
Query.getResultList()
still does not define what (NULL
or an emptyList
) is returned when the result set is empty. So the user either depends on the implemention or has to do an null check when using the method.For example: In old versions of Hibernate the implementation returned
NULL
, newer versions (I can't find since when exactly, but have stopped searching as I looked into the current specs first) return an userfriendly empty list.So I want to suggest to update the specification that such methods are never allowed to return
null
. I know this might be not backward compatible to older specs, but since Jakarta has begun to release non backward compatible specs I think this is a valid change.Beta Was this translation helpful? Give feedback.
All reactions