diff --git a/src/main/java/org/springframework/data/mapping/context/AbstractMappingContext.java b/src/main/java/org/springframework/data/mapping/context/AbstractMappingContext.java index 1d9328ac9..70eadc58d 100644 --- a/src/main/java/org/springframework/data/mapping/context/AbstractMappingContext.java +++ b/src/main/java/org/springframework/data/mapping/context/AbstractMappingContext.java @@ -218,9 +218,34 @@ public abstract class AbstractMappingContext entity = persistentEntities.get(ClassTypeInformation.from(type)); + TypeInformation typeInformation = ClassTypeInformation.from(type); - return entity == null ? false : entity.isPresent(); + try { + + read.lock(); + + // Try the original type first + Optional entity = persistentEntities.get(typeInformation); + + if (entity != null) { + return entity.isPresent(); + } + + // User type is the same? + TypeInformation userTypeInformation = typeInformation.getUserTypeInformation(); + + if (userTypeInformation.equals(typeInformation)) { + return false; + } + + // Try the user type + entity = persistentEntities.get(typeInformation.getUserTypeInformation()); + + return entity == null ? false : entity.isPresent(); + + } finally { + read.unlock(); + } } /* @@ -760,7 +785,8 @@ public abstract class AbstractMappingContext persistentEntityForProxy = context .getRequiredPersistentEntity(Base$$SpringProxy$873fa2e.class);