Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>org.springframework.data</groupId>
<artifactId>spring-data-commons</artifactId>
<version>4.2.0-SNAPSHOT</version>
<version>4.2.0-GH-3500-SNAPSHOT</version>

<name>Spring Data Core</name>
<description>Core Spring concepts underpinning every Spring Data module.</description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -407,8 +407,11 @@ private Map<String, TypeInformation<?>> doGetProperties() {

Map<String, TypeInformation<?>> result = new HashMap<>();
Class<?> type = getType();
FieldCallback callback = field -> result.put(field.getName(),
TypeInformation.of(ResolvableType.forField(field, resolvableType)));
FieldCallback callback = field -> {
if (!result.containsKey(field.getName())) {
result.put(field.getName(), TypeInformation.of(ResolvableType.forField(field, resolvableType)));
}
};

// Inspect fields first
ReflectionUtils.doWithFields(type, callback);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,14 @@ void considersNestedGenericsInEqualityForRecursiveUnresolvableTypes() throws Exc
assertThat(domainType.isAssignableFrom(actualType)).isTrue();
}

@Test // GH-3500
void superclassFieldsDoNotHideSubclassFields() {

TypeDiscoverer<?> discoverer = TypeDiscoverer.ofCached(ResolvableType.forClass(TheOne.class));

assertThat(discoverer.getProperty("theOne").getType()).isEqualTo(String.class);
}

class Person {

Addresses addresses;
Expand Down Expand Up @@ -487,6 +495,16 @@ static abstract class SomeType<Self extends SomeType<Self>> {

}

static class SuperclassWithProperties {
private CharSequence theOne;
private String theOther;
}

class TheOne extends SuperclassWithProperties {
private String theOne;
}


@SuppressWarnings("rawtypes")
interface RepoWithRawGenerics extends Repository<SomeType, SomeType> {

Expand Down
Loading