Browse Source

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

Related pull request: #443.
pull/371/head
Oliver Gierke 9 years ago committed by Christoph Strobl
parent
commit
98a9b66e6b
  1. 5
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoTemplate.java

5
spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoTemplate.java

@ -833,11 +833,10 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware, @@ -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, @@ -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));

Loading…
Cancel
Save