-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Labels
status: waiting-for-triageAn issue we've not yet triagedAn issue we've not yet triaged
Description
When using mongoTemplate.replace(query, entity) to replace a document in the database, the returned value from BeforeConvertCallbacks is not used as the entity to save.
It seems that the callbacks are actually called, but the resulting replacementis not used to create the mappedReplacement, which then gets saved. From Commit 909169d, class org.springframework.data.mongodb.core.MongoTemplate, lines 2153-2186:
protected <S, T> UpdateResult replace(Query query, Class<S> entityType, T replacement, ReplaceOptions options,
String collectionName) {
...
UpdateContext updateContext = queryOperations.replaceSingleContext(query,
operations.forEntity(replacement).toMappedDocument(this.mongoConverter), options.isUpsert());
replacement = maybeCallBeforeConvert(replacement, collectionName);
Document mappedReplacement = updateContext.getMappedUpdate(mappingContext.getPersistentEntity(entityType));
maybeEmitEvent(new BeforeSaveEvent<>(replacement, mappedReplacement, collectionName));
replacement = maybeCallBeforeSave(replacement, mappedReplacement, collectionName);
MongoAction action = new MongoAction(writeConcern, MongoActionOperation.REPLACE, collectionName, entityType,
mappedReplacement, updateContext.getQueryObject());
UpdateResult result = doReplace(options, entityType, collectionName, updateContext,
createCollectionPreparer(query, action), mappedReplacement);
...
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
status: waiting-for-triageAn issue we've not yet triagedAn issue we've not yet triaged