persistence icon indicating copy to clipboard operation
persistence copied to clipboard

add Query.getSingleResultOrNull()

Open gavinking opened this issue 1 year ago • 2 comments

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

gavinking avatar Sep 09 '22 07:09 gavinking

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.

beikov avatar Sep 09 '22 08:09 beikov

Shouldn't it rather be something like this?

Sure, we could do that.

gavinking avatar Sep 09 '22 08:09 gavinking

:+1:

mkalkowski83 avatar Feb 14 '23 07:02 mkalkowski83

add to changelog

Done.

This is ready to merge.

gavinking avatar Aug 07 '23 11:08 gavinking