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

objectResult

open static fun <T : Any> objectResult(@Nullable results: MutableCollection<*>, @Nullable requiredType: Class<T>): T

Return a unique result object from the given Collection. Throws an exception if 0 or more than 1 result objects found, of if the unique result object is not convertible to the specified required type.

Parameters

results - the result Collection (can be null but is not expected to contain null elements)

Exceptions

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

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

TypeMismatchDataAccessException - if the unique object does not match the specified required type

Return
the unique result object