@@ -766,7 +766,7 @@ public long count(final Query query, String collectionName) {
766
766
public long count (Query query , Class <?> entityClass , String collectionName ) {
767
767
768
768
Assert .hasText (collectionName , "Collection name must not be null or empty!" );
769
-
769
+
770
770
final DBObject dbObject = query == null ? null
771
771
: queryMapper .getMappedObject (query .getQueryObject (),
772
772
entityClass == null ? null : mappingContext .getPersistentEntity (entityClass ));
@@ -845,11 +845,10 @@ private WriteConcern potentiallyForceAcknowledgedWrite(WriteConcern wc) {
845
845
846
846
protected <T > void doInsert (String collectionName , T objectToSave , MongoWriter <T > writer ) {
847
847
848
+ initializeVersionProperty (objectToSave );
848
849
maybeEmitEvent (new BeforeConvertEvent <T >(objectToSave , collectionName ));
849
850
assertUpdateableIdIfNotSet (objectToSave );
850
851
851
- initializeVersionProperty (objectToSave );
852
-
853
852
DBObject dbDoc = toDbObject (objectToSave , writer );
854
853
855
854
maybeEmitEvent (new BeforeSaveEvent <T >(objectToSave , dbDoc , collectionName ));
@@ -939,12 +938,13 @@ protected <T> void doInsertBatch(String collectionName, Collection<? extends T>
939
938
Assert .notNull (writer , "MongoWriter must not be null!" );
940
939
941
940
List <DBObject > dbObjectList = new ArrayList <DBObject >();
941
+
942
942
for (T o : batchToSave ) {
943
943
944
944
initializeVersionProperty (o );
945
- BasicDBObject dbDoc = new BasicDBObject ();
946
-
947
945
maybeEmitEvent (new BeforeConvertEvent <T >(o , collectionName ));
946
+
947
+ BasicDBObject dbDoc = new BasicDBObject ();
948
948
writer .write (o , dbDoc );
949
949
950
950
maybeEmitEvent (new BeforeSaveEvent <T >(o , dbDoc , collectionName ));
0 commit comments