首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >由spring-data-rest发布的自定义jpa存储库方法

由spring-data-rest发布的自定义jpa存储库方法
EN

Stack Overflow用户
提问于 2014-01-14 14:52:52
回答 1查看 5.3K关注 0票数 10

我在jpa存储库中添加了一个自定义方法,详见http://docs.spring.io/spring-data/data-jpa/docs/1.0.x/reference/html/#repositories.custom-implementations

据我所见,当我使用spring-data-rest时,没有公开此方法。我是否可以将其作为生成的REST的一部分发布(而无需自己创建Spring控制器)?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-02-01 19:30:10

我检查了代码库--似乎它们已经明确地禁用了自定义方法--不确定原因。以下是来自org.springframework.data.repository.core.support.DefaultRepositoryInformation的相关代码

代码语言:javascript
复制
@Override
public Set<Method> getQueryMethods() {

    Set<Method> result = new HashSet<Method>();

    for (Method method : getRepositoryInterface().getMethods()) {
        method = ClassUtils.getMostSpecificMethod(method, getRepositoryInterface());
        if (isQueryMethodCandidate(method)) {
            result.add(method);
        }
    }

    return Collections.unmodifiableSet(result);
}

/**
 * Checks whether the given method is a query method candidate.
 * 
 * @param method
 * @return
 */
private boolean isQueryMethodCandidate(Method method) {
    return isQueryAnnotationPresentOn(method) || !isCustomMethod(method) && !isBaseClassMethod(method);
}
票数 11
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21116539

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档