Custom jpa repository method published by spring-data-rest

前端 未结 1 728
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-03 12:12

I\'ve added a custom method to a jpa repository as detailed on http://docs.spring.io/spring-data/data-jpa/docs/1.0.x/reference/html/#repositories.custom-implementations

相关标签:
1条回答
  • 2020-12-03 13:00

    I checked the code base - seems like they have explicitily disabled custom methods - not sure why. Here is the relevant piece of code from org.springframework.data.repository.core.support.DefaultRepositoryInformation

    @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);
    }
    
    0 讨论(0)
提交回复
热议问题