|
|
|
@ -108,7 +108,6 @@ import org.springframework.data.mongodb.core.mapping.FieldName; |
|
|
|
import org.springframework.data.mongodb.core.mapping.MongoMappingContext; |
|
|
|
import org.springframework.data.mongodb.core.mapping.MongoMappingContext; |
|
|
|
import org.springframework.data.mongodb.core.mapping.MongoPersistentEntity; |
|
|
|
import org.springframework.data.mongodb.core.mapping.MongoPersistentEntity; |
|
|
|
import org.springframework.data.mongodb.core.mapping.MongoPersistentProperty; |
|
|
|
import org.springframework.data.mongodb.core.mapping.MongoPersistentProperty; |
|
|
|
import org.springframework.data.mongodb.core.mapping.MongoSimpleTypes; |
|
|
|
|
|
|
|
import org.springframework.data.mongodb.core.mapping.event.*; |
|
|
|
import org.springframework.data.mongodb.core.mapping.event.*; |
|
|
|
import org.springframework.data.mongodb.core.mapreduce.MapReduceOptions; |
|
|
|
import org.springframework.data.mongodb.core.mapreduce.MapReduceOptions; |
|
|
|
import org.springframework.data.mongodb.core.query.BasicQuery; |
|
|
|
import org.springframework.data.mongodb.core.query.BasicQuery; |
|
|
|
@ -1368,9 +1367,7 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati |
|
|
|
.flatMap(it -> maybeCallBeforeConvert(it.getSource(), it.getCollection()).map(it::mutate)) //
|
|
|
|
.flatMap(it -> maybeCallBeforeConvert(it.getSource(), it.getCollection()).map(it::mutate)) //
|
|
|
|
.map(it -> { |
|
|
|
.map(it -> { |
|
|
|
|
|
|
|
|
|
|
|
AdaptibleEntity<T> entity = operations.forEntity(it.getSource(), mongoConverter.getConversionService()); |
|
|
|
AdaptibleEntity<T> entity = operations.forEntityUpsert(it.getSource(), mongoConverter.getConversionService()); |
|
|
|
entity.assertUpdateableIdIfNotSet(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PersistableEntityModel<T> model = PersistableEntityModel.of(entity.initializeVersionProperty(), |
|
|
|
PersistableEntityModel<T> model = PersistableEntityModel.of(entity.initializeVersionProperty(), |
|
|
|
entity.toMappedDocument(writer).getDocument(), it.getCollection()); |
|
|
|
entity.toMappedDocument(writer).getDocument(), it.getCollection()); |
|
|
|
|
|
|
|
|
|
|
|
@ -1440,9 +1437,7 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati |
|
|
|
|
|
|
|
|
|
|
|
return maybeCallBeforeConvert(toConvert, collectionName).flatMap(it -> { |
|
|
|
return maybeCallBeforeConvert(toConvert, collectionName).flatMap(it -> { |
|
|
|
|
|
|
|
|
|
|
|
AdaptibleEntity<T> entity = operations.forEntity(it, mongoConverter.getConversionService()); |
|
|
|
AdaptibleEntity<T> entity = operations.forEntityUpsert(it, mongoConverter.getConversionService()); |
|
|
|
entity.assertUpdateableIdIfNotSet(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
T initialized = entity.initializeVersionProperty(); |
|
|
|
T initialized = entity.initializeVersionProperty(); |
|
|
|
MappedDocument mapped = entity.toMappedDocument(writer); |
|
|
|
MappedDocument mapped = entity.toMappedDocument(writer); |
|
|
|
|
|
|
|
|
|
|
|
@ -1558,9 +1553,7 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati |
|
|
|
|
|
|
|
|
|
|
|
return maybeCallBeforeConvert(toSave, collectionName).flatMap(toConvert -> { |
|
|
|
return maybeCallBeforeConvert(toSave, collectionName).flatMap(toConvert -> { |
|
|
|
|
|
|
|
|
|
|
|
AdaptibleEntity<T> entity = operations.forEntity(toConvert, mongoConverter.getConversionService()); |
|
|
|
AdaptibleEntity<T> entity = operations.forEntityUpsert(toConvert, mongoConverter.getConversionService()); |
|
|
|
entity.assertUpdateableIdIfNotSet(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Document dbDoc = entity.toMappedDocument(writer).getDocument(); |
|
|
|
Document dbDoc = entity.toMappedDocument(writer).getDocument(); |
|
|
|
maybeEmitEvent(new BeforeSaveEvent<T>(toConvert, dbDoc, collectionName)); |
|
|
|
maybeEmitEvent(new BeforeSaveEvent<T>(toConvert, dbDoc, collectionName)); |
|
|
|
|
|
|
|
|
|
|
|
@ -2623,7 +2616,7 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Prepare the collection before any processing is done using it. This allows a convenient way to apply settings like |
|
|
|
* Prepare the collection before any processing is done using it. This allows a convenient way to apply settings like |
|
|
|
* withCodecRegistry() etc. Can be overridden in sub-classes. |
|
|
|
* withCodecRegistry() etc. Can be overridden in subclasses. |
|
|
|
* |
|
|
|
* |
|
|
|
* @param collection |
|
|
|
* @param collection |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@ -2647,9 +2640,8 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Prepare the WriteConcern before any processing is done using it. This allows a convenient way to apply custom |
|
|
|
* Prepare the WriteConcern before any processing is done using it. This allows a convenient way to apply custom |
|
|
|
* settings in sub-classes. <br /> |
|
|
|
* settings in subclasses. The returned {@link WriteConcern} will be defaulted to {@link WriteConcern#ACKNOWLEDGED} |
|
|
|
* The returned {@link WriteConcern} will be defaulted to {@link WriteConcern#ACKNOWLEDGED} when |
|
|
|
* when {@link WriteResultChecking} is set to {@link WriteResultChecking#EXCEPTION}. |
|
|
|
* {@link WriteResultChecking} is set to {@link WriteResultChecking#EXCEPTION}. |
|
|
|
|
|
|
|
* |
|
|
|
* |
|
|
|
* @param mongoAction any WriteConcern already configured or {@literal null}. |
|
|
|
* @param mongoAction any WriteConcern already configured or {@literal null}. |
|
|
|
* @return The prepared WriteConcern or {@literal null}. |
|
|
|
* @return The prepared WriteConcern or {@literal null}. |
|
|
|
|