From 43ab3cad1359ce8644c6ef15e55baf862402afc9 Mon Sep 17 00:00:00 2001 From: Oliver Gierke Date: Fri, 24 Mar 2017 12:24:57 +0100 Subject: [PATCH] =?UTF-8?q?DATAMONGO-1647=20-=20Switched=20to=20use=20Iden?= =?UTF-8?q?tifierAccessor.getRequiredIdentifier()=20in=20MongoTemplate.doS?= =?UTF-8?q?aveVersioned(=E2=80=A6).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/springframework/data/mongodb/core/MongoTemplate.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoTemplate.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoTemplate.java index 08e8d08fe..95ca4ffeb 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoTemplate.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoTemplate.java @@ -1000,8 +1000,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware, // Create query for entity with the id and old version MongoPersistentProperty idProperty = entity.getRequiredIdProperty(); - Object id = convertingAccessor.getProperty(idProperty) - .orElseThrow(() -> new IllegalStateException("Required id not found!")); + Object id = entity.getIdentifierAccessor(objectToSave).getRequiredIdentifier(); Query query = new Query(Criteria.where(idProperty.getName()).is(id).and(property.getName()).is(number)); UpdateResult result = doUpdate(collectionName, query, update, objectToSave.getClass(), false, false);