Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QueryExecutorMethodInterceptor does not delegate custom method execution to ImplementationMethodExecutionInterceptor [DATACMNS-1472] #1905

Open
spring-projects-issues opened this issue Jan 22, 2019 · 0 comments
Assignees
Labels
in: repository type: bug

Comments

@spring-projects-issues
Copy link

@spring-projects-issues spring-projects-issues commented Jan 22, 2019

kchobantonov opened DATACMNS-1472 and commented

In spring-data-commons 1.8.0.RELEASE the QueryExecutorMethodInterceptor implementation checked if the query method is also a custom method and invoked the implementation method instead if this was the case.

Now since the query method execution and custom method (implementation) execution are separated into QueryExecutorMethodInterceptor and ImplementationMethodExecutionInterceptor, the new QueryExecutorMethodInterceptor no longer checks if the query method is also a custom method to skip it (effectively delegating the execution to ImplementationMethodExecutionInterceptor object)

Solutions

1) 

If we want to preserve the backward compatibility then we could change the QueryExecutorMethodInterceptor doInvoke method to skip any custom methods. So change 

 

if (hasQueryFor(method)) { 
  return queries.get(method).execute(arguments); 
}

 

to the following code (assuming that the passed RepositoryInformation parameter to the constructor is preserved as a field in that class )

 

if (hasQueryFor(method) && !repositoryInformation.isCustomMethod(method)) { 
   return queries.get(method).execute(arguments); 
}

 

  1. If the new functionality is desired then

Make creation of QueryExecutorMethodInterceptor extensible, currently we need to override 

public <T> T getRepository( Class<T> repositoryInterface, RepositoryFragments fragments )

that is in org.springframework.data.repository.core.support.RepositoryFactorySupport class

which refers to private methods - validate, getRepositoryComposition, getRepositoryInformation as well as private postProcessors field that forces us to use reflection to call those methods (validate could be simply copied over to the subclass but not the rest)

Make also the QueryExecutorMethodInterceptor extensible by changing the visibility for doInvoke(MethodInvocation invocation) from private to protected so that we can alter the doInvoke method to check for implementation methods as well - if the default is not going to be modified.

 

As separate note : should we change the visibility for org.springframework.data.repository.core.support.QueryExecutionResultHandler class from package to public if we want to extend it ?

Why we need a method to be both - query method and custom implementation method

The reason why the custom implementation method is annotated with a query annotation (custom query annotation that is annotated with org.springframework.data.annotation.QueryAnnotation) is because we need that repository method to be automatically exported as REST endpoint by RepositorySearchController


Affects: 2.1.4 (Lovelace SR4)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: repository type: bug
Projects
None yet
Development

No branches or pull requests

2 participants