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 ea4c3f971..773efa2b6 100644 --- a/src/main/java/org/springframework/data/mapping/model/AbstractPersistentProperty.java +++ b/src/main/java/org/springframework/data/mapping/model/AbstractPersistentProperty.java @@ -23,13 +23,11 @@ import java.lang.reflect.Method; import java.util.Collections; import java.util.Map; import java.util.Optional; -import java.util.regex.Pattern; import org.springframework.data.annotation.Reference; import org.springframework.data.mapping.Association; import org.springframework.data.mapping.PersistentEntity; import org.springframework.data.mapping.PersistentProperty; -import org.springframework.data.mapping.PropertyPath; import org.springframework.data.util.Lazy; import org.springframework.data.util.ReflectionUtils; import org.springframework.data.util.TypeInformation; @@ -74,9 +72,8 @@ public abstract class AbstractPersistentProperty
Assert.notNull(owner, "Owner entity must not be null!");
this.name = property.getName();
- this.rawType = property.getType();
- this.information = PropertyPath.from(Pattern.quote(property.getName()), owner.getTypeInformation())
- .getTypeInformation();
+ this.information = owner.getTypeInformation().getRequiredProperty(getName());
+ this.rawType = this.information.getType();
this.property = property;
this.association = Lazy.of(() -> isAssociation() ? createAssociation() : null);
this.owner = owner;
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 028ef07fc..a1c286644 100755
--- a/src/test/java/org/springframework/data/mapping/model/AbstractPersistentPropertyUnitTests.java
+++ b/src/test/java/org/springframework/data/mapping/model/AbstractPersistentPropertyUnitTests.java
@@ -200,6 +200,14 @@ public class AbstractPersistentPropertyUnitTests {
assertThat(property.getName()).isEqualTo("var_name_with_underscores");
}
+ @Test // DATACMNS-1139
+ public void resolvesGenericsForRawType() {
+
+ SamplePersistentProperty property = getProperty(FirstConcrete.class, "genericField");
+
+ assertThat(property.getRawType()).isEqualTo(String.class);
+ }
+
private