Adapt repository to List-based interface variants.

Closes #306
This commit is contained in:
Mark Paluch
2022-02-11 11:06:55 +01:00
parent fa405e6076
commit c78fe9add4
3 changed files with 8 additions and 18 deletions

View File

@@ -21,6 +21,7 @@ import java.util.Optional;
import javax.naming.Name;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.ListCrudRepository;
import org.springframework.ldap.query.LdapQuery;
/**
@@ -29,16 +30,7 @@ import org.springframework.ldap.query.LdapQuery;
* @author Mattias Hellborg Arthursson
* @author Mark Paluch
*/
public interface LdapRepository<T> extends CrudRepository<T, Name> {
@Override
<S extends T> List<S> saveAll(Iterable<S> entities);
@Override
List<T> findAll();
@Override
List<T> findAllById(Iterable<Name> names);
public interface LdapRepository<T> extends ListCrudRepository<T, Name> {
/**
* Find one entry matching the specified query.
@@ -55,5 +47,5 @@ public interface LdapRepository<T> extends CrudRepository<T, Name> {
* @param ldapQuery the query specification.
* @return the entries matching the query.
*/
Iterable<T> findAll(LdapQuery ldapQuery);
List<T> findAll(LdapQuery ldapQuery);
}

View File

@@ -22,7 +22,6 @@ import org.springframework.data.mapping.PersistentEntity;
import org.springframework.data.mapping.PersistentProperty;
import org.springframework.data.mapping.context.MappingContext;
import org.springframework.data.mapping.model.EntityInstantiators;
import org.springframework.data.repository.query.Parameters;
import org.springframework.data.repository.query.RepositoryQuery;
import org.springframework.data.repository.query.ReturnedType;
import org.springframework.data.repository.query.parser.PartTree;
@@ -39,7 +38,6 @@ import org.springframework.ldap.query.LdapQuery;
public class PartTreeLdapRepositoryQuery extends AbstractLdapRepositoryQuery {
private final PartTree partTree;
private final Parameters<?, ?> parameters;
private final ObjectDirectoryMapper objectDirectoryMapper;
/**
@@ -58,7 +56,6 @@ public class PartTreeLdapRepositoryQuery extends AbstractLdapRepositoryQuery {
super(queryMethod, entityType, ldapOperations, mappingContext, instantiators);
partTree = new PartTree(queryMethod.getName(), entityType);
parameters = queryMethod.getParameters();
objectDirectoryMapper = ldapOperations.getObjectDirectoryMapper();
}

View File

@@ -38,6 +38,7 @@ import org.springframework.data.mapping.context.MappingContext;
import org.springframework.data.mapping.model.EntityInstantiators;
import org.springframework.data.projection.ProjectionFactory;
import org.springframework.data.projection.ProjectionInformation;
import org.springframework.data.querydsl.ListQuerydslPredicateExecutor;
import org.springframework.data.querydsl.QuerydslPredicateExecutor;
import org.springframework.data.repository.core.EntityInformation;
import org.springframework.data.repository.query.FluentQuery;
@@ -56,7 +57,7 @@ import com.querydsl.core.types.Predicate;
* @author Mark Paluch
* @since 2.6
*/
public class QuerydslLdapPredicateExecutor<T> implements QuerydslPredicateExecutor<T> {
public class QuerydslLdapPredicateExecutor<T> implements ListQuerydslPredicateExecutor<T> {
private final EntityInformation<T, ?> entityInformation;
private final ProjectionFactory projectionFactory;
@@ -129,7 +130,7 @@ public class QuerydslLdapPredicateExecutor<T> implements QuerydslPredicateExecut
return findBy(predicate, FluentQuery.FetchableFluentQuery::exists);
}
public Iterable<T> findAll(Predicate predicate, Sort sort) {
public List<T> findAll(Predicate predicate, Sort sort) {
Assert.notNull(sort, "Pageable must not be null!");
@@ -140,7 +141,7 @@ public class QuerydslLdapPredicateExecutor<T> implements QuerydslPredicateExecut
throw new UnsupportedOperationException("Sorting is not supported");
}
public Iterable<T> findAll(OrderSpecifier<?>... orders) {
public List<T> findAll(OrderSpecifier<?>... orders) {
if (orders.length == 0) {
return findAll();
@@ -150,7 +151,7 @@ public class QuerydslLdapPredicateExecutor<T> implements QuerydslPredicateExecut
}
@Override
public Iterable<T> findAll(Predicate predicate, OrderSpecifier<?>... orders) {
public List<T> findAll(Predicate predicate, OrderSpecifier<?>... orders) {
if (orders.length == 0) {
return findAll(predicate);