From f747f3df60493c35488710520ee3b0c9c0dafcb6 Mon Sep 17 00:00:00 2001 From: Oliver Gierke Date: Wed, 16 Mar 2011 11:47:06 +0100 Subject: [PATCH] Only consider properties that are backed by a field actually. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Changed MongoPropertyDescriptor.isMappable(…) to check whether the owning type actually has a field with the property name. If not the property will not be regarded as mappable. This results in plain functional getters (that are not a bean property getter actually) to be skipped transparently. --- .../mongodb/MongoPropertyDescriptors.java | 15 ++++++++++++--- .../data/document/mongodb/MongoTemplate.java | 2 +- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/document/mongodb/MongoPropertyDescriptors.java b/spring-data-mongodb/src/main/java/org/springframework/data/document/mongodb/MongoPropertyDescriptors.java index 2ea985ffb..9f82ddd0d 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/document/mongodb/MongoPropertyDescriptors.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/document/mongodb/MongoPropertyDescriptors.java @@ -24,6 +24,7 @@ import java.util.*; import org.bson.types.ObjectId; import org.springframework.beans.BeanUtils; import org.springframework.util.Assert; +import org.springframework.util.ReflectionUtils; /** * An iterable of {@link MongoPropertyDescriptor}s that allows dedicated access to the {@link MongoPropertyDescriptor} @@ -48,7 +49,7 @@ public class MongoPropertyDescriptors implements Iterable owningType; /** * Creates a new {@link MongoPropertyDescriptor} for the given {@link PropertyDescriptor}. * * @param descriptor + * @param owningType */ - public MongoPropertyDescriptor(PropertyDescriptor descriptor) { + public MongoPropertyDescriptor(PropertyDescriptor descriptor, Class owningType) { Assert.notNull(descriptor); this.delegate = descriptor; + this.owningType = owningType; } /** @@ -154,7 +158,12 @@ public class MongoPropertyDescriptors implements Iterable