Unify entity type detection.

Unified the calculations made for entityTypeInformation and entityTypes in AbstractPersistentProperty. This avoids both calculations getting out of sync. Also we avoid premature calculation abortions if SimpleTypeHolder.isSimpleType(…) returns true for the raw property type. The latter has caused issues for collection properties in Spring Data KeyValue which considers everything in java.util a simple type.

Related ticket: #2390.
This commit is contained in:
Oliver Drotbohm
2021-07-08 18:36:16 +02:00
parent ab74551928
commit b3b590dcf0
2 changed files with 60 additions and 66 deletions

View File

@@ -295,6 +295,24 @@ class AbstractMappingContextUnitTests {
.doesNotContain(List.class, ArrayList.class);
}
@Test // GH-2390
void detectsEntityTypeEveneIfSimpleTypeHolderConsidersCollectionsSimple() {
context.setSimpleTypeHolder(new SimpleTypeHolder(Collections.emptySet(), true) {
@Override
public boolean isSimpleType(Class<?> type) {
return type.getName().startsWith("java.util.");
}
});
context.getPersistentEntity(WithNestedLists.class);
assertThat(context.getPersistentEntities()) //
.map(it -> (Class) it.getType()) //
.contains(Base.class);
}
@Test // GH-2390
void shouldNotCreatePersistentEntityForMapButItsGenericTypeArguments() {