/** * Creates a new {@link QueryExecutorMethodInterceptor}. Builds a model of {@link QueryMethod}s to be invoked on * execution of repository interface methods. */ public QueryExecutorMethodInterceptor(RepositoryInformation repositoryInformation, ProjectionFactory projectionFactory) { this.resultHandler = new QueryExecutionResultHandler(); Optional<QueryLookupStrategy> lookupStrategy = getQueryLookupStrategy(queryLookupStrategyKey, RepositoryFactorySupport.this.evaluationContextProvider); if (!lookupStrategy.isPresent() && repositoryInformation.hasQueryMethods()) { throw new IllegalStateException("You have defined query method in the repository but " + "you don't have any query lookup strategy defined. The " + "infrastructure apparently does not support query methods!"); } this.queries = lookupStrategy // .map(it -> mapMethodsToQuery(repositoryInformation, it, projectionFactory)) // .orElse(Collections.emptyMap()); }
/** * Creates a new {@link QueryExecutorMethodInterceptor}. Builds a model of {@link QueryMethod}s to be invoked on * execution of repository interface methods. */ public QueryExecutorMethodInterceptor(RepositoryInformation repositoryInformation, Object customImplementation, Object target) { this.repositoryInformation = repositoryInformation; this.customImplementation = customImplementation; this.target = target; QueryLookupStrategy lookupStrategy = getQueryLookupStrategy(queryLookupStrategyKey); Iterable<Method> queryMethods = repositoryInformation.getQueryMethods(); if (lookupStrategy == null) { if (queryMethods.iterator().hasNext()) { throw new IllegalStateException("You have defined query method in the repository but " + "you don't have no query lookup strategy defined. The " + "infrastructure apparently does not support query methods!"); } return; } for (Method method : queryMethods) { RepositoryQuery query = lookupStrategy.resolveQuery(method, repositoryInformation, namedQueries); invokeListeners(query); queries.put(method, query); } }