Polishing.
Reformat code. Reuse PersistentEntity for mapping instead of resolving TypeInformation from Class. Original pull request: #4892 See: #4860
This commit is contained in:
@@ -20,9 +20,10 @@ import java.util.Optional;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.bson.Document;
|
||||
|
||||
import org.springframework.dao.IncorrectResultSizeDataAccessException;
|
||||
import org.springframework.data.domain.Window;
|
||||
import org.springframework.data.domain.ScrollPosition;
|
||||
import org.springframework.data.domain.Window;
|
||||
import org.springframework.data.mongodb.core.query.NearQuery;
|
||||
import org.springframework.data.mongodb.core.query.Query;
|
||||
import org.springframework.data.mongodb.core.query.SerializationUtils;
|
||||
@@ -228,11 +229,13 @@ class ExecutableFindOperationSupport implements ExecutableFindOperation {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public ReadPreference getReadPreference() {
|
||||
return delegate.getReadPreference();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Document getSortObject() {
|
||||
return delegate instanceof SortingQueryCursorPreparer sqcp ? sqcp.getSortObject() : null;
|
||||
}
|
||||
|
||||
@@ -2624,7 +2624,9 @@ public class MongoTemplate
|
||||
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
|
||||
Document mappedSort = preparer instanceof SortingQueryCursorPreparer sqcp ? getMappedSortObject(sqcp.getSortObject(), sourceClass) : null;
|
||||
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",
|
||||
serializeToJsonSafely(mappedQuery), mappedFields, serializeToJsonSafely(mappedSort), sourceClass,
|
||||
collectionName));
|
||||
@@ -2993,7 +2995,7 @@ public class MongoTemplate
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Document getMappedSortObject(Document sortObject, MongoPersistentEntity<?> entity) {
|
||||
private Document getMappedSortObject(Document sortObject, @Nullable MongoPersistentEntity<?> entity) {
|
||||
|
||||
if (ObjectUtils.isEmpty(sortObject)) {
|
||||
return null;
|
||||
@@ -3355,11 +3357,8 @@ public class MongoTemplate
|
||||
class QueryCursorPreparer implements SortingQueryCursorPreparer {
|
||||
|
||||
private final Query query;
|
||||
|
||||
private final Document sortObject;
|
||||
|
||||
private final int limit;
|
||||
|
||||
private final long skip;
|
||||
private final @Nullable Class<?> type;
|
||||
|
||||
|
||||
@@ -19,10 +19,14 @@ import org.bson.Document;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* {@link CursorPreparer} that exposes its {@link Document sort document}.
|
||||
*
|
||||
* @author Christoph Strobl
|
||||
* @since 4.3.9
|
||||
*/
|
||||
interface SortingQueryCursorPreparer extends CursorPreparer {
|
||||
|
||||
@Nullable
|
||||
Document getSortObject();
|
||||
@Nullable
|
||||
Document getSortObject();
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user