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

uniqueResult

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

Return a unique result object from the given Collection.

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

Parameters

results - the result Collection (can be null)

Exceptions

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

Return
the unique result object, or null if none

See Also
org.springframework.util.CollectionUtils#hasUniqueObject