private Document getMappedSortObject(Query query, Class<?> type) { if (query == null) { return null; } return queryMapper.getMappedSort(query.getSortObject(), mappingContext.getPersistentEntity(type)); }
private Document getMappedSortObject(Query query, Class<?> type) { if (query == null || ObjectUtils.isEmpty(query.getSortObject())) { return null; } return queryMapper.getMappedSort(query.getSortObject(), mappingContext.getPersistentEntity(type)); }
@Override public <S, T> Mono<T> findAndReplace(Query query, S replacement, FindAndReplaceOptions options, Class<S> entityType, String collectionName, Class<T> resultType) { Assert.notNull(query, "Query must not be null!"); Assert.notNull(replacement, "Replacement must not be null!"); Assert.notNull(options, "Options must not be null! Use FindAndReplaceOptions#empty() instead."); Assert.notNull(entityType, "Entity class must not be null!"); Assert.notNull(collectionName, "CollectionName must not be null!"); Assert.notNull(resultType, "ResultType must not be null! Use Object.class instead."); Assert.isTrue(query.getLimit() <= 1, "Query must not define a limit other than 1 ore none!"); Assert.isTrue(query.getSkip() <= 0, "Query must not define skip."); MongoPersistentEntity<?> entity = mappingContext.getPersistentEntity(entityType); Document mappedQuery = queryMapper.getMappedObject(query.getQueryObject(), entity); Document mappedFields = queryMapper.getMappedFields(query.getFieldsObject(), entity); Document mappedSort = queryMapper.getMappedSort(query.getSortObject(), entity); Document mappedReplacement = operations.forEntity(replacement).toMappedDocument(this.mongoConverter).getDocument(); return doFindAndReplace(collectionName, mappedQuery, mappedFields, mappedSort, query.getCollation().map(Collation::toMongoCollation).orElse(null), entityType, mappedReplacement, options, resultType); }
@Override public <S, T> T findAndReplace(Query query, S replacement, FindAndReplaceOptions options, Class<S> entityType, String collectionName, Class<T> resultType) { Assert.notNull(query, "Query must not be null!"); Assert.notNull(replacement, "Replacement must not be null!"); Assert.notNull(options, "Options must not be null! Use FindAndReplaceOptions#empty() instead."); Assert.notNull(entityType, "EntityType must not be null!"); Assert.notNull(collectionName, "CollectionName must not be null!"); Assert.notNull(resultType, "ResultType must not be null! Use Object.class instead."); Assert.isTrue(query.getLimit() <= 1, "Query must not define a limit other than 1 ore none!"); Assert.isTrue(query.getSkip() <= 0, "Query must not define skip."); MongoPersistentEntity<?> entity = mappingContext.getPersistentEntity(entityType); Document mappedQuery = queryMapper.getMappedObject(query.getQueryObject(), entity); Document mappedFields = queryMapper.getMappedFields(query.getFieldsObject(), entity); Document mappedSort = queryMapper.getMappedSort(query.getSortObject(), entity); Document mappedReplacement = operations.forEntity(replacement).toMappedDocument(this.mongoConverter).getDocument(); return doFindAndReplace(collectionName, mappedQuery, mappedFields, mappedSort, query.getCollation().map(Collation::toMongoCollation).orElse(null), entityType, mappedReplacement, options, resultType); }
private Document getMappedSortObject(Query query, Class<?> type) { if (query == null) { return null; } return queryMapper.getMappedSort(query.getSortObject(), mappingContext.getPersistentEntity(type)); }
private Document getMappedSortObject(Query query, Class<?> type) { if (query == null || ObjectUtils.isEmpty(query.getSortObject())) { return null; } return queryMapper.getMappedSort(query.getSortObject(), mappingContext.getPersistentEntity(type)); }
@Override public <S, T> T findAndReplace(Query query, S replacement, FindAndReplaceOptions options, Class<S> entityType, String collectionName, Class<T> resultType) { Assert.notNull(query, "Query must not be null!"); Assert.notNull(replacement, "Replacement must not be null!"); Assert.notNull(options, "Options must not be null! Use FindAndReplaceOptions#empty() instead."); Assert.notNull(entityType, "EntityType must not be null!"); Assert.notNull(collectionName, "CollectionName must not be null!"); Assert.notNull(resultType, "ResultType must not be null! Use Object.class instead."); Assert.isTrue(query.getLimit() <= 1, "Query must not define a limit other than 1 ore none!"); Assert.isTrue(query.getSkip() <= 0, "Query must not define skip."); MongoPersistentEntity<?> entity = mappingContext.getPersistentEntity(entityType); Document mappedQuery = queryMapper.getMappedObject(query.getQueryObject(), entity); Document mappedFields = queryMapper.getMappedFields(query.getFieldsObject(), entity); Document mappedSort = queryMapper.getMappedSort(query.getSortObject(), entity); Document mappedReplacement = operations.forEntity(replacement).toMappedDocument(this.mongoConverter).getDocument(); return doFindAndReplace(collectionName, mappedQuery, mappedFields, mappedSort, query.getCollation().map(Collation::toMongoCollation).orElse(null), entityType, mappedReplacement, options, resultType); }
@Override public <S, T> Mono<T> findAndReplace(Query query, S replacement, FindAndReplaceOptions options, Class<S> entityType, String collectionName, Class<T> resultType) { Assert.notNull(query, "Query must not be null!"); Assert.notNull(replacement, "Replacement must not be null!"); Assert.notNull(options, "Options must not be null! Use FindAndReplaceOptions#empty() instead."); Assert.notNull(entityType, "Entity class must not be null!"); Assert.notNull(collectionName, "CollectionName must not be null!"); Assert.notNull(resultType, "ResultType must not be null! Use Object.class instead."); Assert.isTrue(query.getLimit() <= 1, "Query must not define a limit other than 1 ore none!"); Assert.isTrue(query.getSkip() <= 0, "Query must not define skip."); MongoPersistentEntity<?> entity = mappingContext.getPersistentEntity(entityType); Document mappedQuery = queryMapper.getMappedObject(query.getQueryObject(), entity); Document mappedFields = queryMapper.getMappedFields(query.getFieldsObject(), entity); Document mappedSort = queryMapper.getMappedSort(query.getSortObject(), entity); Document mappedReplacement = operations.forEntity(replacement).toMappedDocument(this.mongoConverter).getDocument(); return doFindAndReplace(collectionName, mappedQuery, mappedFields, mappedSort, query.getCollation().map(Collation::toMongoCollation).orElse(null), entityType, mappedReplacement, options, resultType); }