Spring LDAP Repositories

Spring LDAP 具有对 Spring Data 存储库的内置支持。基本功能和配置在 here 中进行了说明。在使用 Spring LDAP 存储库时,请记住:

Spring LDAP has built-in support for Spring Data repositories. The basic functionality and configuration is described here. When working with Spring LDAP repositories, you should remember the following:

  • You can enable Spring LDAP repositories by using an <ldap:repositories> element in your XML configuration or by using an @EnableLdapRepositories annotation on a configuration class.

  • To include support for LdapQuery parameters in automatically generated repositories, have your interface extend LdapRepository rather than CrudRepository.

  • All Spring LDAP repositories must work with entities that are annotated with the ODM annotations, as described in Object-Directory Mapping (ODM).

  • Since all ODM managed classes must have a Distinguished Name as the ID, all Spring LDAP repositories must have the ID type parameter set to javax.naming.Name. The built-in LdapRepository takes only one type parameter: the managed entity class, defaulting the ID to javax.naming.Name.

  • Due to specifics of the LDAP protocol, paging and sorting are not supported for Spring LDAP repositories.

QueryDSL support

基本 QueryDSL 支持包含在 Spring LDAP 中。此支持包括以下内容:

Basic QueryDSL support is included in Spring LDAP. This support includes the following:

  • An annotation processor, called LdapAnnotationProcessor, for generating QueryDSL classes based on Spring LDAP ODM annotations. See Object-Directory Mapping (ODM) for more information on the ODM annotations.

  • A Query implementation, called QueryDslLdapQuery, for building and running QueryDSL queries in code.

  • Spring Data repository support for QueryDSL predicates. QueryDslPredicateExecutor includes a number of additional methods with appropriate parameters. You can extend this interface along with LdapRepository to include this support in your repository.