DATAMONGO-1617 - Reinstantiate version property initialization before BeforeConvertEvent publication.

Related pull request: #443.
This commit is contained in:
Oliver Gierke
2017-02-28 20:05:35 +01:00
committed by Christoph Strobl
parent 827b6204a9
commit 98a9b66e6b

View File

@@ -833,11 +833,10 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
protected <T> void doInsert(String collectionName, T objectToSave, MongoWriter<T> writer) {
initializeVersionProperty(objectToSave);
maybeEmitEvent(new BeforeConvertEvent<T>(objectToSave, collectionName));
assertUpdateableIdIfNotSet(objectToSave);
initializeVersionProperty(objectToSave);
Document dbDoc = toDocument(objectToSave, writer);
maybeEmitEvent(new BeforeSaveEvent<T>(objectToSave, dbDoc, collectionName));
@@ -940,8 +939,8 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
for (T o : batchToSave) {
initializeVersionProperty(o);
maybeEmitEvent(new BeforeConvertEvent<T>(o, collectionName));
Document document = toDocument(o, writer);
maybeEmitEvent(new BeforeSaveEvent<T>(o, document, collectionName));