|
|
|
@ -2615,7 +2615,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware, |
|
|
|
|
|
|
|
|
|
|
|
if (LOGGER.isDebugEnabled()) { |
|
|
|
if (LOGGER.isDebugEnabled()) { |
|
|
|
|
|
|
|
|
|
|
|
Document mappedSort = getMappedSortObject(query, entityClass); |
|
|
|
Document mappedSort = preparer instanceof SortingQueryCursorPreparer sqcp ? getMappedSortObject(sqcp.getSortObject(), entity) : null; |
|
|
|
LOGGER.debug(String.format("find using query: %s fields: %s sort: %s for class: %s in collection: %s", |
|
|
|
LOGGER.debug(String.format("find using query: %s fields: %s sort: %s for class: %s in collection: %s", |
|
|
|
serializeToJsonSafely(mappedQuery), mappedFields, serializeToJsonSafely(mappedSort), entityClass, |
|
|
|
serializeToJsonSafely(mappedQuery), mappedFields, serializeToJsonSafely(mappedSort), entityClass, |
|
|
|
collectionName)); |
|
|
|
collectionName)); |
|
|
|
@ -2640,9 +2640,10 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware, |
|
|
|
QueryContext queryContext = queryOperations.createQueryContext(new BasicQuery(query, fields)); |
|
|
|
QueryContext queryContext = queryOperations.createQueryContext(new BasicQuery(query, fields)); |
|
|
|
Document mappedFields = queryContext.getMappedFields(entity, projection); |
|
|
|
Document mappedFields = queryContext.getMappedFields(entity, projection); |
|
|
|
Document mappedQuery = queryContext.getMappedQuery(entity); |
|
|
|
Document mappedQuery = queryContext.getMappedQuery(entity); |
|
|
|
Document mappedSort = getMappedSortObject(query, sourceClass); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (LOGGER.isDebugEnabled()) { |
|
|
|
if (LOGGER.isDebugEnabled()) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Document mappedSort = preparer instanceof SortingQueryCursorPreparer sqcp ? getMappedSortObject(sqcp.getSortObject(), sourceClass) : null; |
|
|
|
LOGGER.debug(String.format("find using query: %s fields: %s sort: %s for class: %s in collection: %s", |
|
|
|
LOGGER.debug(String.format("find using query: %s fields: %s sort: %s for class: %s in collection: %s", |
|
|
|
serializeToJsonSafely(mappedQuery), mappedFields, serializeToJsonSafely(mappedSort), sourceClass, |
|
|
|
serializeToJsonSafely(mappedQuery), mappedFields, serializeToJsonSafely(mappedSort), sourceClass, |
|
|
|
collectionName)); |
|
|
|
collectionName)); |
|
|
|
@ -3006,12 +3007,17 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware, |
|
|
|
|
|
|
|
|
|
|
|
@Nullable |
|
|
|
@Nullable |
|
|
|
private Document getMappedSortObject(Document sortObject, Class<?> type) { |
|
|
|
private Document getMappedSortObject(Document sortObject, Class<?> type) { |
|
|
|
|
|
|
|
return getMappedSortObject(sortObject, mappingContext.getPersistentEntity(type)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Nullable |
|
|
|
|
|
|
|
private Document getMappedSortObject(Document sortObject, MongoPersistentEntity<?> entity) { |
|
|
|
|
|
|
|
|
|
|
|
if (ObjectUtils.isEmpty(sortObject)) { |
|
|
|
if (ObjectUtils.isEmpty(sortObject)) { |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return queryMapper.getMappedSort(sortObject, mappingContext.getPersistentEntity(type)); |
|
|
|
return queryMapper.getMappedSort(sortObject, entity); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
@ -3364,7 +3370,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware, |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
class QueryCursorPreparer implements CursorPreparer { |
|
|
|
class QueryCursorPreparer implements SortingQueryCursorPreparer { |
|
|
|
|
|
|
|
|
|
|
|
private final Query query; |
|
|
|
private final Query query; |
|
|
|
|
|
|
|
|
|
|
|
@ -3462,6 +3468,11 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware, |
|
|
|
return cursorToUse; |
|
|
|
return cursorToUse; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Nullable |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public Document getSortObject() { |
|
|
|
|
|
|
|
return sortObject; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
|