DATAKV-90 - Add findAll variant with QueryDSL OrderSpecifier without a Predicate.

This commit is contained in:
Christoph Strobl
2014-11-28 15:06:08 +01:00
parent 5f62882a3e
commit 4f37a7ecc3
2 changed files with 48 additions and 2 deletions

View File

@@ -29,6 +29,7 @@ import org.springframework.data.querydsl.QueryDslPredicateExecutor;
import org.springframework.data.querydsl.SimpleEntityPathResolver;
import org.springframework.data.repository.core.EntityInformation;
import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;
import com.mysema.query.collections.CollQuery;
import com.mysema.query.support.ProjectableQuery;
@@ -136,6 +137,23 @@ public class QueryDslKeyValueRepository<T, ID extends Serializable> extends Simp
return new PageImpl<T>(query.list(builder), pageable, count(predicate));
}
/*
* (non-Javadoc)
* @see org.springframework.data.querydsl.QueryDslPredicateExecutor#findAll(com.mysema.query.types.OrderSpecifier[])
*/
@Override
public Iterable<T> findAll(OrderSpecifier<?>... orders) {
if (ObjectUtils.isEmpty(orders)) {
return findAll();
}
ProjectableQuery<?> query = prepareQuery(null);
query.orderBy(orders);
return query.list(builder);
}
/*
* (non-Javadoc)
* @see org.springframework.data.querydsl.QueryDslPredicateExecutor#count(com.mysema.query.types.Predicate)
@@ -156,8 +174,10 @@ public class QueryDslKeyValueRepository<T, ID extends Serializable> extends Simp
CollQuery query = new CollQuery();
query.from(builder, findAll());
query.where(predicate);
if (predicate != null) {
query.where(predicate);
}
return query;
}
}