How to properly get sorted records from LDAP directory. Loading all to memory and then sorting is time consuming because of big amount of data. That is why i want (with Spring Boot/SpringLDAP) get already sorted records from LDAP.
I tried to create in @Repository
@Repository
public interface XxxRepository extends LdapRepository<Xxx>, Serializable {
List<Xxx> findAllByOrderByNameAsc(LdapQuery ldapQuery);
}
It does not work, NullPointerException.
My @Entity looks like:
@Entry(base = "", objectClasses = {"xxx", "xxx"})
public class Xxx implements Serializable {
@Id
private Name dn;
@Attribute(name = "name")
@DnAttribute(value = "name", index = 0)
private String name;
.
.
.
}
My @Service
public void search() {
String filterConditions = "(&(objectClass=Xxx)";
filterConditions += "(name=*)";
LdapQuery query = query().base(BASE_UNIT).filter(filterConditions + ")");
List<Xxx> xxx= xxxRepository.findAllByOrderByNameAsc(query);
}