@@ -496,11 +496,10 @@ public <T> Flux<T> execute(ReactiveSessionCallback<T> action, Consumer<ClientSes
496
496
session .startTransaction ();
497
497
}
498
498
499
- return Flux
500
- .usingWhen (Mono .just (session ), //
501
- s -> ReactiveMongoTemplate .this .withSession (action , s ), //
502
- ClientSession ::commitTransaction , //
503
- ClientSession ::abortTransaction ) //
499
+ return Flux .usingWhen (Mono .just (session ), //
500
+ s -> ReactiveMongoTemplate .this .withSession (action , s ), //
501
+ ClientSession ::commitTransaction , //
502
+ ClientSession ::abortTransaction ) //
504
503
.doFinally (signalType -> doFinally .accept (session ));
505
504
});
506
505
}
@@ -742,18 +741,22 @@ public Mono<Boolean> exists(Query query, String collectionName) {
742
741
* (non-Javadoc)
743
742
* @see org.springframework.data.mongodb.core.ReactiveMongoOperations#exists(org.springframework.data.mongodb.core.query.Query, java.lang.Class, java.lang.String)
744
743
*/
745
- public Mono <Boolean > exists (final Query query , @ Nullable Class <?> entityClass , String collectionName ) {
744
+ public Mono <Boolean > exists (Query query , @ Nullable Class <?> entityClass , String collectionName ) {
746
745
747
746
if (query == null ) {
748
747
throw new InvalidDataAccessApiUsageException ("Query passed in to exist can't be null" );
749
748
}
750
749
751
750
return createFlux (collectionName , collection -> {
752
751
753
- Document mappedQuery = queryMapper .getMappedObject (query .getQueryObject (), getPersistentEntity (entityClass ));
754
- FindPublisher <Document > findPublisher = collection .find (mappedQuery , Document .class )
752
+ Document filter = queryMapper .getMappedObject (query .getQueryObject (), getPersistentEntity (entityClass ));
753
+ FindPublisher <Document > findPublisher = collection .find (filter , Document .class )
755
754
.projection (new Document ("_id" , 1 ));
756
755
756
+ if (LOGGER .isDebugEnabled ()) {
757
+ LOGGER .debug ("exists: {} in collection: {}" , serializeToJsonSafely (filter ), collectionName );
758
+ }
759
+
757
760
findPublisher = query .getCollation ().map (Collation ::toMongoCollation ).map (findPublisher ::collation )
758
761
.orElse (findPublisher );
759
762
@@ -835,6 +838,11 @@ public <T> Flux<T> findDistinct(Query query, String field, String collectionName
835
838
836
839
Flux <?> result = execute (collectionName , collection -> {
837
840
841
+ if (LOGGER .isDebugEnabled ()) {
842
+ LOGGER .debug ("Executing findDistinct using query {} for field: {} in collection: {}" ,
843
+ serializeToJsonSafely (mappedQuery ), field , collectionName );
844
+ }
845
+
838
846
DistinctPublisher <T > publisher = collection .distinct (mappedFieldName , mappedQuery , mongoDriverCompatibleType );
839
847
840
848
return query .getCollation ().map (Collation ::toMongoCollation ).map (publisher ::collation ).orElse (publisher );
@@ -1151,7 +1159,7 @@ public Mono<Long> count(Query query, @Nullable Class<?> entityClass, String coll
1151
1159
1152
1160
return createMono (collectionName , collection -> {
1153
1161
1154
- final Document Document = query == null ? null
1162
+ Document filter = query == null ? null
1155
1163
: queryMapper .getMappedObject (query .getQueryObject (),
1156
1164
entityClass == null ? null : mappingContext .getPersistentEntity (entityClass ));
1157
1165
@@ -1160,7 +1168,11 @@ public Mono<Long> count(Query query, @Nullable Class<?> entityClass, String coll
1160
1168
query .getCollation ().map (Collation ::toMongoCollation ).ifPresent (options ::collation );
1161
1169
}
1162
1170
1163
- return collection .count (Document , options );
1171
+ if (LOGGER .isDebugEnabled ()) {
1172
+ LOGGER .debug ("Executing count: {} in collection: {}" , serializeToJsonSafely (filter ), collectionName );
1173
+ }
1174
+
1175
+ return collection .count (filter , options );
1164
1176
});
1165
1177
}
1166
1178
@@ -3165,7 +3177,7 @@ public Mono<Long> count(Query query, @Nullable Class<?> entityClass, String coll
3165
3177
3166
3178
return createMono (collectionName , collection -> {
3167
3179
3168
- final Document Document = query == null ? null
3180
+ Document filter = query == null ? null
3169
3181
: delegate .queryMapper .getMappedObject (query .getQueryObject (),
3170
3182
entityClass == null ? null : delegate .mappingContext .getPersistentEntity (entityClass ));
3171
3183
@@ -3174,7 +3186,11 @@ public Mono<Long> count(Query query, @Nullable Class<?> entityClass, String coll
3174
3186
query .getCollation ().map (Collation ::toMongoCollation ).ifPresent (options ::collation );
3175
3187
}
3176
3188
3177
- return collection .countDocuments (Document , options );
3189
+ if (LOGGER .isDebugEnabled ()) {
3190
+ LOGGER .debug ("Executing count: {} in collection: {}" , serializeToJsonSafely (filter ), collectionName );
3191
+ }
3192
+
3193
+ return collection .countDocuments (filter , options );
3178
3194
});
3179
3195
}
3180
3196
}
0 commit comments