【问题标题】:Spring Data LDAP using Pageable is it possible?使用 Pageable 的 Spring Data LDAP 是否可能?
【发布时间】:2017-10-24 13:21:49
【问题描述】:

我使用 spring Data LDAP,我想返回除页面之外的所有用户。 findAll 工作但返回所有用户。

我尝试使用用户 Page<UserLdap> findAll(Pageable pageable);,但出现错误:

Caused by: org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'userLdapRepository':
Invocation of init method failed;
nested exception is org.springframework.data.mapping.PropertyReferenceException:
No property findAll found for type UserLdap!

完整代码:

public interface UserLdapRepository extends LdapRepository<UserLdap> {
    Set<UserLdap> findAll();
    Page<UserLdap> findAll(Pageable pageable);
}

我尝试添加extends PagingAndSortingRepository&lt;UserLdap, Name&gt;,但我遇到了同样的错误。

完整代码:

public interface UserLdapRepository extends PagingAndSortingRepository<UserLdap, Name>, LdapRepository<UserLdap> {
    Set<UserLdap> findAll();
    Page<UserLdap> findAll(Pageable pageable);
}

是否可以将 Pageable 与 Spring Data LDAP 一起使用?

编辑:

我在 Spring Data ldap 中找到了这段代码:

public Page<T> findAll(Predicate predicate, Pageable pageable) { ...

请问它是什么谓词?如果你有样品,我很高兴:)

【问题讨论】:

    标签: java spring-data querydsl spring-ldap


    【解决方案1】:

    这是不可能的:

    UnsupportedOperationException()

    @Override
    public Page<T> findAll(Predicate predicate, Pageable pageable) {
        throw new UnsupportedOperationException();
    }
    

    【讨论】:

      【解决方案2】:

      “由于 LDAP 协议的特殊性,Spring LDAP 存储库不支持分页和排序。”

      https://docs.spring.io/spring-data/ldap/docs/current/reference/html/#ldap.repositories中查看更多信息

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2016-05-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-08-05
        • 2016-09-11
        • 1970-01-01
        相关资源
        最近更新 更多