From c78fe9add445bdbe33c8f74018e849a4b52a2db8 Mon Sep 17 00:00:00 2001 From: Mark Paluch Date: Fri, 11 Feb 2022 11:06:55 +0100 Subject: [PATCH] Adapt repository to List-based interface variants. Closes #306 --- .../data/ldap/repository/LdapRepository.java | 14 +++----------- .../query/PartTreeLdapRepositoryQuery.java | 3 --- .../support/QuerydslLdapPredicateExecutor.java | 9 +++++---- 3 files changed, 8 insertions(+), 18 deletions(-) diff --git a/src/main/java/org/springframework/data/ldap/repository/LdapRepository.java b/src/main/java/org/springframework/data/ldap/repository/LdapRepository.java index 306c0d4..0981870 100644 --- a/src/main/java/org/springframework/data/ldap/repository/LdapRepository.java +++ b/src/main/java/org/springframework/data/ldap/repository/LdapRepository.java @@ -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 extends CrudRepository { - - @Override - List saveAll(Iterable entities); - - @Override - List findAll(); - - @Override - List findAllById(Iterable names); +public interface LdapRepository extends ListCrudRepository { /** * Find one entry matching the specified query. @@ -55,5 +47,5 @@ public interface LdapRepository extends CrudRepository { * @param ldapQuery the query specification. * @return the entries matching the query. */ - Iterable findAll(LdapQuery ldapQuery); + List findAll(LdapQuery ldapQuery); } diff --git a/src/main/java/org/springframework/data/ldap/repository/query/PartTreeLdapRepositoryQuery.java b/src/main/java/org/springframework/data/ldap/repository/query/PartTreeLdapRepositoryQuery.java index e5f3606..24d8146 100644 --- a/src/main/java/org/springframework/data/ldap/repository/query/PartTreeLdapRepositoryQuery.java +++ b/src/main/java/org/springframework/data/ldap/repository/query/PartTreeLdapRepositoryQuery.java @@ -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(); } diff --git a/src/main/java/org/springframework/data/ldap/repository/support/QuerydslLdapPredicateExecutor.java b/src/main/java/org/springframework/data/ldap/repository/support/QuerydslLdapPredicateExecutor.java index 48ae3a1..9153665 100644 --- a/src/main/java/org/springframework/data/ldap/repository/support/QuerydslLdapPredicateExecutor.java +++ b/src/main/java/org/springframework/data/ldap/repository/support/QuerydslLdapPredicateExecutor.java @@ -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 implements QuerydslPredicateExecutor { +public class QuerydslLdapPredicateExecutor implements ListQuerydslPredicateExecutor { private final EntityInformation entityInformation; private final ProjectionFactory projectionFactory; @@ -129,7 +130,7 @@ public class QuerydslLdapPredicateExecutor implements QuerydslPredicateExecut return findBy(predicate, FluentQuery.FetchableFluentQuery::exists); } - public Iterable findAll(Predicate predicate, Sort sort) { + public List findAll(Predicate predicate, Sort sort) { Assert.notNull(sort, "Pageable must not be null!"); @@ -140,7 +141,7 @@ public class QuerydslLdapPredicateExecutor implements QuerydslPredicateExecut throw new UnsupportedOperationException("Sorting is not supported"); } - public Iterable findAll(OrderSpecifier... orders) { + public List findAll(OrderSpecifier... orders) { if (orders.length == 0) { return findAll(); @@ -150,7 +151,7 @@ public class QuerydslLdapPredicateExecutor implements QuerydslPredicateExecut } @Override - public Iterable findAll(Predicate predicate, OrderSpecifier... orders) { + public List findAll(Predicate predicate, OrderSpecifier... orders) { if (orders.length == 0) { return findAll(predicate);