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

singleResult

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

Return a single result object from the given Collection.

Returns null if 0 result objects found; throws an exception if more than 1 element found.

Parameters

results - the result Collection (can be null)

Exceptions

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

Return
the single result object, or null if none