jakartaee / persistence

https://jakartaee.github.io/persistence/
Other
191 stars 55 forks source link

add Query.getSingleResultOrNull() #384

Closed gavinking closed 12 months ago

gavinking commented 1 year ago

Adds the new method I proposed in this discussion: https://github.com/jakartaee/persistence/issues/298#issuecomment-736682475.

beikov commented 1 year ago

Shouldn't it rather be something like this?

    default T getSingleResultOrNull() {
        try {
            return getSingleResult();
        } catch (NoResultException e) {
            return null;
        }
    }

Given that getResultStream was also added with a default implementation.

gavinking commented 1 year ago

Shouldn't it rather be something like this?

Sure, we could do that.

mkalkowski83 commented 1 year ago

:+1:

gavinking commented 12 months ago

add to changelog

Done.

This is ready to merge.