spring-framework / org.springframework.dao.support / DataAccessUtils / nullableSingleResult

nullableSingleResult

@Nullable open static fun <T : Any> nullableSingleResult(@Nullable results: MutableCollection<T>): T

Return a single result object from the given Collection.

Throws an exception if 0 or more than 1 element found.

Parameters

results - the result Collection (can be null and is also expected to contain null elements)

Exceptions

IncorrectResultSizeDataAccessException - if more than one element has been found in the given Collection

EmptyResultDataAccessException - if no element at all has been found in the given Collection

Return
the single result object

Since
5.0.2