Skip to content

Commit 93a5295

Browse files
KSH-codemp911de
authored andcommitted
Add sort to query debug logging.
Closes #4686 Original pull request: #4679
1 parent 0815c6d commit 93a5295

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

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

+6-4
Original file line numberDiff line numberDiff line change
@@ -2587,10 +2587,11 @@ protected <S, T> List<T> doFind(String collectionName,
25872587
QueryContext queryContext = queryOperations.createQueryContext(new BasicQuery(query, fields));
25882588
Document mappedFields = queryContext.getMappedFields(entity, EntityProjection.nonProjecting(entityClass));
25892589
Document mappedQuery = queryContext.getMappedQuery(entity);
2590+
Document mappedSort = getMappedSortObject(query, entityClass);
25902591

25912592
if (LOGGER.isDebugEnabled()) {
2592-
LOGGER.debug(String.format("find using query: %s fields: %s for class: %s in collection: %s",
2593-
serializeToJsonSafely(mappedQuery), mappedFields, entityClass, collectionName));
2593+
LOGGER.debug(String.format("find using query: %s fields: %s sort: %s for class: %s in collection: %s",
2594+
serializeToJsonSafely(mappedQuery), mappedSort, mappedFields, entityClass, collectionName));
25942595
}
25952596

25962597
return executeFindMultiInternal(new FindCallback(collectionPreparer, mappedQuery, mappedFields, null),
@@ -2612,10 +2613,11 @@ <S, T> List<T> doFind(CollectionPreparer<MongoCollection<Document>> collectionPr
26122613
QueryContext queryContext = queryOperations.createQueryContext(new BasicQuery(query, fields));
26132614
Document mappedFields = queryContext.getMappedFields(entity, projection);
26142615
Document mappedQuery = queryContext.getMappedQuery(entity);
2616+
Document mappedSort = getMappedSortObject(query, sourceClass);
26152617

26162618
if (LOGGER.isDebugEnabled()) {
2617-
LOGGER.debug(String.format("find using query: %s fields: %s for class: %s in collection: %s",
2618-
serializeToJsonSafely(mappedQuery), mappedFields, sourceClass, collectionName));
2619+
LOGGER.debug(String.format("find using query: %s fields: %s sort: %s for class: %s in collection: %s",
2620+
serializeToJsonSafely(mappedQuery), mappedSort, mappedFields, sourceClass, collectionName));
26192621
}
26202622

26212623
return executeFindMultiInternal(new FindCallback(collectionPreparer, mappedQuery, mappedFields, null), preparer,

0 commit comments

Comments
 (0)