DATAKV-159 - Adapt to API changes in Spring Data Commons.

This commit is contained in:
Oliver Gierke
2017-03-23 10:10:10 +01:00
committed by Christoph Strobl
parent 71d2bfb254
commit c9ce2f1f72
2 changed files with 8 additions and 9 deletions

View File

@@ -16,10 +16,8 @@
package org.springframework.data.keyvalue.repository.query;
import java.lang.reflect.Constructor;
import java.util.Optional;
import org.springframework.beans.BeanUtils;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
@@ -87,7 +85,7 @@ public class KeyValuePartTreeQuery implements RepositoryQuery {
ParameterAccessor accessor = new ParametersParameterAccessor(getQueryMethod().getParameters(), parameters);
KeyValueQuery<?> query = prepareQuery(parameters);
ResultProcessor processor = queryMethod.getResultProcessor().withDynamicProjection(Optional.ofNullable(accessor));
ResultProcessor processor = queryMethod.getResultProcessor().withDynamicProjection(accessor);
return processor.processResult(doExecute(parameters, query));
}
@@ -151,9 +149,9 @@ public class KeyValuePartTreeQuery implements RepositoryQuery {
Pageable pageable = accessor.getPageable();
Sort sort = accessor.getSort();
query.setOffset(pageable != null && Pageable.NONE.equals(pageable) ? -1L : pageable.getOffset());
query.setOffset(pageable.toOptional().map(Pageable::getOffset).orElse(-1L));
if (pageable != null && !Pageable.NONE.equals(pageable)) {
if (pageable.isPaged()) {
query.setRows(pageable.getPageSize());
} else if (instance.getRows() >= 0) {
query.setRows(instance.getRows());

View File

@@ -75,14 +75,14 @@ public class SimpleKeyValueRepository<T, ID extends Serializable> implements Key
if (pageable == null) {
List<T> result = findAll();
return new PageImpl<T>(result, Pageable.NONE, result.size());
return new PageImpl<T>(result, Pageable.unpaged(), result.size());
}
Iterable<T> content = operations.findInRange(pageable.getOffset(), pageable.getPageSize(), pageable.getSort(),
entityInformation.getJavaType());
return new PageImpl<T>(IterableConverter.toList(content), pageable, this.operations.count(entityInformation
.getJavaType()));
return new PageImpl<T>(IterableConverter.toList(content), pageable,
this.operations.count(entityInformation.getJavaType()));
}
/*
@@ -188,7 +188,8 @@ public class SimpleKeyValueRepository<T, ID extends Serializable> implements Key
*/
@Override
public void delete(T entity) {
delete(entityInformation.getId(entity).orElseThrow(() -> new IllegalArgumentException("Cannot delete entity with 'null' id.")));
delete(entityInformation.getId(entity)
.orElseThrow(() -> new IllegalArgumentException("Cannot delete entity with 'null' id.")));
}
/*