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

requiredSingleResult

open static fun <T : Any> requiredSingleResult(@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 but is not 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