diff --git a/src/main/java/org/springframework/data/mapping/model/BasicPersistentEntity.java b/src/main/java/org/springframework/data/mapping/model/BasicPersistentEntity.java index 308d3d053..716e005ed 100644 --- a/src/main/java/org/springframework/data/mapping/model/BasicPersistentEntity.java +++ b/src/main/java/org/springframework/data/mapping/model/BasicPersistentEntity.java @@ -35,6 +35,7 @@ import org.springframework.data.annotation.TypeAlias; import org.springframework.data.domain.Persistable; import org.springframework.data.mapping.*; import org.springframework.data.spel.EvaluationContextProvider; +import org.springframework.data.spel.ExpressionDependencies; import org.springframework.data.support.IsNewStrategy; import org.springframework.data.support.PersistableIsNewStrategy; import org.springframework.data.util.Lazy; @@ -537,10 +538,29 @@ public class BasicPersistentEntity> implement }; } + /** + * Obtain a {@link EvaluationContext} for a {@code rootObject}. + * + * @param rootObject must not be {@literal null}. + * @return the evaluation context including all potential extensions. + * @since 2.1 + */ protected EvaluationContext getEvaluationContext(Object rootObject) { return evaluationContextProvider.getEvaluationContext(rootObject); } + /** + * Obtain a {@link EvaluationContext} for a {@code rootObject} given {@link ExpressionDependencies}. + * + * @param rootObject must not be {@literal null}. + * @param dependencies must not be {@literal null}. + * @return the evaluation context with extensions loaded that satisfy {@link ExpressionDependencies}. + * @since 2.5 + */ + protected EvaluationContext getEvaluationContext(Object rootObject, ExpressionDependencies dependencies) { + return evaluationContextProvider.getEvaluationContext(rootObject, dependencies); + } + /** * Returns the default {@link IsNewStrategy} to be used. Will be a {@link PersistentEntityIsNewStrategy} by default. * Note, that this strategy only gets used if the entity doesn't implement {@link Persistable} as this indicates the