DATAJPA-1392 - Allow lenient PersistentEntity lookup via JPA Metamodel.

JpaMetamodelMappingContext now overrides ….hasPersistentEntityFor(…) to fall back to a JPA Metamodel lookup check as only checking the cache might not be sufficient as it's not eagerly populated anymore.
This commit is contained in:
Oliver Gierke
2018-08-14 13:08:02 +02:00
parent 746c5b2db7
commit 6d1bc47f06

View File

@@ -100,6 +100,15 @@ public class JpaMetamodelMappingContext
return doFindPersistentPropertyPaths(type, predicate, it -> it.isEmbeddable());
}
/*
* (non-Javadoc)
* @see org.springframework.data.mapping.context.AbstractMappingContext#hasPersistentEntityFor(java.lang.Class)
*/
@Override
public boolean hasPersistentEntityFor(Class<?> type) {
return super.hasPersistentEntityFor(type) || models.isMetamodelManagedType(type);
}
/**
* A wrapper for a set of JPA {@link Metamodel} instances to simplify lookups of {@link JpaMetamodel} instances and
* managed type checks.
@@ -129,13 +138,23 @@ public class JpaMetamodelMappingContext
}
/**
* Retruns whether the given type is managed by one of the underlying {@link Metamodel} instances.
* Returns whether the given type is managed by one of the underlying {@link Metamodel} instances.
*
* @param type must not be {@literal null}.
* @return
*/
public boolean isMetamodelManagedType(TypeInformation<?> type) {
return getMetamodelFor(type.getType()) != null;
return isMetamodelManagedType(type.getType());
}
/**
* Returns whether the given type is managed by one of the underlying {@link Metamodel} instances.
*
* @param type must not be {@literal null}.
* @return
*/
public boolean isMetamodelManagedType(Class<?> type) {
return getMetamodelFor(type) != null;
}
/**