DATACMNS-1354 - BasicPersistentEntity now exposes means to override the fallback IsNewStrategy.
This is useful in case a particular store implementation needs to customize the default is new detection.
This commit is contained in:
@@ -131,7 +131,8 @@ public class BasicPersistentEntity<T, P extends PersistentProperty<P>> implement
|
||||
this.typeAlias = Lazy.of(() -> getAliasFromAnnotation(getType()));
|
||||
this.isNewStrategy = Lazy.of(() -> Persistable.class.isAssignableFrom(information.getType()) //
|
||||
? PersistableIsNewStrategy.INSTANCE
|
||||
: PersistentEntityIsNewStrategy.of(this));
|
||||
: getFallbackIsNewStrategy());
|
||||
|
||||
this.isImmutable = Lazy.of(() -> isAnnotationPresent(Immutable.class));
|
||||
}
|
||||
|
||||
@@ -520,6 +521,18 @@ public class BasicPersistentEntity<T, P extends PersistentProperty<P>> implement
|
||||
return evaluationContextProvider.getEvaluationContext(rootObject);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
* user wants to be in control over whether an entity is new or not.
|
||||
*
|
||||
* @return
|
||||
* @since 2.1
|
||||
*/
|
||||
protected IsNewStrategy getFallbackIsNewStrategy() {
|
||||
return PersistentEntityIsNewStrategy.of(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies the given bean type to no be {@literal null} and of the type of the current {@link PersistentEntity}.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user