diff --git a/spring-data-commons-core/src/main/java/org/springframework/data/mapping/model/AbstractPersistentProperty.java b/spring-data-commons-core/src/main/java/org/springframework/data/mapping/model/AbstractPersistentProperty.java index efe954d00..da3d91c6c 100644 --- a/spring-data-commons-core/src/main/java/org/springframework/data/mapping/model/AbstractPersistentProperty.java +++ b/spring-data-commons-core/src/main/java/org/springframework/data/mapping/model/AbstractPersistentProperty.java @@ -177,7 +177,8 @@ public abstract class AbstractPersistentProperty
protected boolean isEntity() { - boolean isComplexType = !simpleTypeHolder.isSimpleType(information.getActualType().getType()); + TypeInformation> actualType = information.getActualType(); + boolean isComplexType = actualType == null ? false : !simpleTypeHolder.isSimpleType(actualType.getType()); return isComplexType && !isTransient() && !isCollectionLike() && !isMap(); } diff --git a/spring-data-commons-core/src/test/java/org/springframework/data/mapping/model/AbstractPersistentPropertyUnitTests.java b/spring-data-commons-core/src/test/java/org/springframework/data/mapping/model/AbstractPersistentPropertyUnitTests.java index 393a18265..0fc1956f7 100644 --- a/spring-data-commons-core/src/test/java/org/springframework/data/mapping/model/AbstractPersistentPropertyUnitTests.java +++ b/spring-data-commons-core/src/test/java/org/springframework/data/mapping/model/AbstractPersistentPropertyUnitTests.java @@ -5,6 +5,8 @@ import static org.junit.Assert.*; import java.beans.PropertyDescriptor; import java.lang.reflect.Field; +import java.util.Collection; +import java.util.Map; import java.util.TreeSet; import org.junit.Before; @@ -54,14 +56,39 @@ public class AbstractPersistentPropertyUnitTests { assertThat(property.getPersistentEntityType().iterator().hasNext(), is(false)); } + /** + * @see DATACMNS-132 + */ + @Test + public void isEntityWorksForUntypedMaps() throws Exception { + + Field field = ReflectionUtils.findField(TestClassComplex.class, "map"); + SamplePersistentProperty property = new SamplePersistentProperty(field, null, entity, typeHolder); + assertThat(property.isEntity(), is(false)); + } + + /** + * @see DATACMNS-132 + */ + @Test + public void isEntityWorksForUntypedCollection() throws Exception { + + Field field = ReflectionUtils.findField(TestClassComplex.class, "collection"); + SamplePersistentProperty property = new SamplePersistentProperty(field, null, entity, typeHolder); + assertThat(property.isEntity(), is(false)); + } + @SuppressWarnings("serial") class TestClassSet extends TreeSet