DATAJPA-1116 - Polishing.
Remove whitespaces and update JavaDoc. Use Pageable.isUnpaged() & Sort.isUnsorted() where possible. Original pull request: #203.
This commit is contained in:
committed by
Mark Paluch
parent
60c8328001
commit
34d3f8121a
@@ -25,7 +25,7 @@ import org.springframework.data.jpa.domain.Specification;
|
||||
|
||||
/**
|
||||
* Interface to allow execution of {@link Specification}s based on the JPA criteria API.
|
||||
*
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
* @author Christoph Strobl
|
||||
*/
|
||||
@@ -33,7 +33,7 @@ public interface JpaSpecificationExecutor<T> {
|
||||
|
||||
/**
|
||||
* Returns a single entity matching the given {@link Specification} or {@link Optional#empty()} if none found.
|
||||
*
|
||||
*
|
||||
* @param spec can be @literal {@null}.
|
||||
* @return
|
||||
* @throws org.springframework.dao.IncorrectResultSizeDataAccessException if more than one entity found.
|
||||
@@ -42,35 +42,35 @@ public interface JpaSpecificationExecutor<T> {
|
||||
|
||||
/**
|
||||
* Returns all entities matching the given {@link Specification}.
|
||||
*
|
||||
* @param spec
|
||||
* @return
|
||||
*
|
||||
* @param spec can be {@literal null}.
|
||||
* @return never {@literal null}.
|
||||
*/
|
||||
List<T> findAll(Specification<T> spec);
|
||||
|
||||
/**
|
||||
* Returns a {@link Page} of entities matching the given {@link Specification}.
|
||||
*
|
||||
* @param spec
|
||||
* @param pageable
|
||||
* @return
|
||||
*
|
||||
* @param spec can be {@literal null}.
|
||||
* @param pageable can be {@literal null}.
|
||||
* @return never {@literal null}.
|
||||
*/
|
||||
Page<T> findAll(Specification<T> spec, Pageable pageable);
|
||||
|
||||
/**
|
||||
* Returns all entities matching the given {@link Specification} and {@link Sort}.
|
||||
*
|
||||
* @param spec
|
||||
* @param sort
|
||||
* @return
|
||||
*
|
||||
* @param spec can be {@literal null}.
|
||||
* @param sort can be {@literal null}.
|
||||
* @return never {@literal null}.
|
||||
*/
|
||||
List<T> findAll(Specification<T> spec, Sort sort);
|
||||
|
||||
/**
|
||||
* Returns the number of instances that the given {@link Specification} will return.
|
||||
*
|
||||
* @param spec the {@link Specification} to count instances for
|
||||
* @return the number of instances
|
||||
*
|
||||
* @param spec the {@link Specification} to count instances for. Can be {@literal null}.
|
||||
* @return the number of instances.
|
||||
*/
|
||||
long count(Specification<T> spec);
|
||||
}
|
||||
|
||||
@@ -381,7 +381,7 @@ public class SimpleJpaRepository<T, ID> implements JpaRepository<T, ID>, JpaSpec
|
||||
public Page<T> findAll(Specification<T> spec, Pageable pageable) {
|
||||
|
||||
TypedQuery<T> query = getQuery(spec, pageable);
|
||||
return pageable == null ? new PageImpl<T>(query.getResultList())
|
||||
return (pageable == null || pageable.isUnpaged()) ? new PageImpl<T>(query.getResultList())
|
||||
: readPage(query, getDomainClass(), pageable, spec);
|
||||
}
|
||||
|
||||
@@ -452,11 +452,11 @@ public class SimpleJpaRepository<T, ID> implements JpaRepository<T, ID>, JpaSpec
|
||||
@Override
|
||||
public <S extends T> Page<S> findAll(Example<S> example, Pageable pageable) {
|
||||
|
||||
ExampleSpecification<S> spec = new ExampleSpecification<S>(example);
|
||||
ExampleSpecification<S> spec = new ExampleSpecification<>(example);
|
||||
Class<S> probeType = example.getProbeType();
|
||||
TypedQuery<S> query = getQuery(new ExampleSpecification<S>(example), probeType, pageable);
|
||||
TypedQuery<S> query = getQuery(new ExampleSpecification<>(example), probeType, pageable);
|
||||
|
||||
return pageable == null ? new PageImpl<S>(query.getResultList()) : readPage(query, probeType, pageable, spec);
|
||||
return pageable == null ? new PageImpl<>(query.getResultList()) : readPage(query, probeType, pageable, spec);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -624,7 +624,7 @@ public class SimpleJpaRepository<T, ID> implements JpaRepository<T, ID>, JpaSpec
|
||||
Root<S> root = applySpecificationToCriteria(spec, domainClass, query);
|
||||
query.select(root);
|
||||
|
||||
if (sort != null && !ObjectUtils.nullSafeEquals(sort, Sort.unsorted())) {
|
||||
if (sort != null && !sort.isUnsorted()) {
|
||||
query.orderBy(toOrders(sort, root, builder));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user