|
这个版本仍在开发中,目前尚未被认为是稳定的。要使用最新稳定版本,请使用 Spring LDAP 4.0.2! |
Spring LDAP 仓库
Spring LDAP 内置支持 Spring Data 仓库。基本功能和配置已在 此处 描述。在使用 Spring LDAP 仓库时,请记住以下几点:
-
你可以通过在 XML 配置中使用
<ldap:repositories>元素,或者在配置类上使用@EnableLdapRepositories注解来启用 Spring LDAP 仓库。 -
若要在自动生成的仓库中包含对
LdapQuery参数的支持,请让您的接口继承LdapRepository,而不是CrudRepository。 -
所有基于 Spring LDAP 的仓库都必须与使用 Object-Directory Mapping (ODM) 注解注释的实体一起工作,如在对象目录映射(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-inLdapRepositorytakes only one type parameter: the managed entity class, defaulting the ID tojavax.naming.Name. -
由于 LDAP 协议的特性,Spring LDAP 仓库不支持分页和排序。
QueryDSL 支持
基础的 QueryDSL 支持包含在 Spring LDAP 中。该支持包括以下内容:
-
一个名为
LdapAnnotationProcessor的注解处理器,用于根据Spring LDAP ODM注解生成QueryDSL类。请参阅对象-目录映射(ODM)以了解更多关于ODM注解的信息。 -
一个查询实现,称为
QueryDslLdapQuery,用于在代码中构建和运行QueryDSL查询。 -
Spring Data仓库对QueryDSL谓词的存储库支持。代码
QueryDslPredicateExecutor包括一组带有适当参数的额外方法。你可以将此接口与LdapRepository扩展,以在你的仓库中包含这种支持。