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:
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user