diff --git a/src/main/java/org/springframework/data/mapping/model/AbstractPersistentProperty.java b/src/main/java/org/springframework/data/mapping/model/AbstractPersistentProperty.java index b39569c7f..1093c5172 100644 --- a/src/main/java/org/springframework/data/mapping/model/AbstractPersistentProperty.java +++ b/src/main/java/org/springframework/data/mapping/model/AbstractPersistentProperty.java @@ -18,8 +18,7 @@ package org.springframework.data.mapping.model; import java.beans.PropertyDescriptor; import java.lang.reflect.Field; import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.List; +import java.util.Collections; import java.util.Map; import org.springframework.core.annotation.AnnotationUtils; @@ -125,23 +124,23 @@ public abstract class AbstractPersistentProperty
@Override
public Iterable extends TypeInformation>> getPersistentEntityType() {
- List
*/
@Override
public boolean isEntity() {
-
- TypeInformation> actualType = information.getActualType();
- boolean isComplexType = actualType == null ? false : !simpleTypeHolder.isSimpleType(actualType.getType());
- return isComplexType && !isTransient();
+ return !isTransient() && getTypeInformationIfEntityCandidate() != null;
}
/*
diff --git a/src/test/java/org/springframework/data/mapping/model/AbstractPersistentPropertyUnitTests.java b/src/test/java/org/springframework/data/mapping/model/AbstractPersistentPropertyUnitTests.java
index de273bd2a..df63d816d 100644
--- a/src/test/java/org/springframework/data/mapping/model/AbstractPersistentPropertyUnitTests.java
+++ b/src/test/java/org/springframework/data/mapping/model/AbstractPersistentPropertyUnitTests.java
@@ -26,6 +26,7 @@ import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.util.Collection;
import java.util.Map;
+import java.util.TreeMap;
import java.util.TreeSet;
import org.junit.Before;
@@ -260,6 +261,17 @@ public class AbstractPersistentPropertyUnitTests {
assertThat(property.isEntity(), is(false));
}
+ /**
+ * @see DATACMNS-562
+ */
+ @Test
+ public void doesNotConsiderPropertyWithTreeMapMapValueAnEntity() {
+
+ SamplePersistentProperty property = getProperty(TreeMapWrapper.class, "map");
+ assertThat(property.getPersistentEntityType(), is(emptyIterable()));
+ assertThat(property.isEntity(), is(false));
+ }
+
private