Fixed getSingleResult to check for hasSingleResult first to avoid issues with provider implementations.