From bb8a4d93c642e66dd38e1f1a7c86ed41170fa09f Mon Sep 17 00:00:00 2001 From: Oliver Gierke Date: Mon, 14 Feb 2011 14:32:02 +0100 Subject: [PATCH] =?UTF-8?q?Use=20newly=20introduced=20findOne(=E2=80=A6)?= =?UTF-8?q?=20of=20MongoOperations=20inside=20SimpleMongoRepository.findBy?= =?UTF-8?q?Id(=E2=80=A6).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../document/mongodb/repository/SimpleMongoRepository.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/document/mongodb/repository/SimpleMongoRepository.java b/spring-data-mongodb/src/main/java/org/springframework/data/document/mongodb/repository/SimpleMongoRepository.java index b387cb767..9c00add21 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/document/mongodb/repository/SimpleMongoRepository.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/document/mongodb/repository/SimpleMongoRepository.java @@ -106,13 +106,10 @@ public class SimpleMongoRepository extends public T findById(ID id) { MongoConverter converter = template.getConverter(); - ObjectId objectId = converter.convertObjectId(id); - List result = - template.find(getCollectionName(getDomainClass()), new Query( - where("_id").is(objectId)), getDomainClass()); - return result.isEmpty() ? null : result.get(0); + return template.findOne(getCollectionName(getDomainClass()), new Query( + where("_id").is(objectId)), getDomainClass()); }