org.springframework.data.repository.query.ResultProcessor Java Examples
The following examples show how to use
org.springframework.data.repository.query.ResultProcessor.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Neo4jQuerySupport.java From sdn-rx with Apache License 2.0 | 6 votes |
protected final BiFunction<TypeSystem, Record, ?> getMappingFunction(final ResultProcessor resultProcessor) { final Class<?> returnedType = resultProcessor.getReturnedType().getReturnedType(); final BiFunction<TypeSystem, Record, ?> mappingFunction; if (Neo4jSimpleTypes.HOLDER.isSimpleType(returnedType)) { // Clients automatically selects a single value mapping function. // It will thrown an error if the query contains more than one column. mappingFunction = null; } else if (resultProcessor.getReturnedType().isProjecting()) { if (returnedType.isInterface()) { mappingFunction = this.mappingContext.getRequiredMappingFunctionFor(domainType); } else if (this.mappingContext.hasPersistentEntityFor(returnedType)) { mappingFunction = this.mappingContext.getRequiredMappingFunctionFor(returnedType); } else { this.mappingContext.addPersistentEntity(returnedType); mappingFunction = this.mappingContext.getRequiredMappingFunctionFor(returnedType); } } else { mappingFunction = this.mappingContext.getRequiredMappingFunctionFor(domainType); } return mappingFunction; }
Example #2
Source File: AbstractNeo4jQuery.java From sdn-rx with Apache License 2.0 | 6 votes |
@Override public final Object execute(Object[] parameters) { Neo4jParameterAccessor parameterAccessor = getParameterAccessor(parameters); ResultProcessor resultProcessor = queryMethod.getResultProcessor().withDynamicProjection(parameterAccessor); PreparedQuery<?> preparedQuery = prepareQuery(resultProcessor.getReturnedType().getReturnedType(), getInputProperties(resultProcessor), parameterAccessor, null, getMappingFunction(resultProcessor)); Object rawResult = new DefaultQueryExecution(neo4jOperations).execute( preparedQuery, queryMethod.isCollectionLikeQuery() || queryMethod.isPageQuery()); Object processedResult = resultProcessor.processResult(rawResult, OptionalUnwrappingConverter.INSTANCE); if (!queryMethod.isPageQuery()) { return processedResult; } else { return PageableExecutionUtils.getPage((List<?>) processedResult, parameterAccessor.getPageable(), () -> { PreparedQuery<Long> countQuery = prepareQuery(Long.class, Collections.emptyList(), parameterAccessor, Neo4jQueryType.COUNT, null); return neo4jOperations.toExecutableQuery(countQuery).getRequiredSingleResult(); }); } }
Example #3
Source File: AbstractReactiveNeo4jQuery.java From sdn-rx with Apache License 2.0 | 5 votes |
@Override public final Object execute(Object[] parameters) { Neo4jParameterAccessor parameterAccessor = getParameterAccessor(parameters); ResultProcessor resultProcessor = queryMethod.getResultProcessor().withDynamicProjection(parameterAccessor); PreparedQuery<?> preparedQuery = prepareQuery(resultProcessor.getReturnedType().getReturnedType(), getInputProperties(resultProcessor), parameterAccessor, null, getMappingFunction(resultProcessor)); Object rawResult = new Neo4jQueryExecution.ReactiveQueryExecution(neo4jOperations).execute( preparedQuery, queryMethod.isCollectionLikeQuery()); return resultProcessor.processResult(rawResult, OptionalUnwrappingConverter.INSTANCE); }
Example #4
Source File: AbstractArangoQuery.java From spring-data with Apache License 2.0 | 5 votes |
private Class<?> getTypeToRead(final ResultProcessor processor) { if (isExistsQuery()) { return Integer.class; } if (method.isGeoQuery()) { return VPackSlice.class; } final Class<?> typeToRead = processor.getReturnedType().getTypeToRead(); return typeToRead != null ? typeToRead : Map.class; }
Example #5
Source File: AbstractCosmosQuery.java From spring-data-cosmosdb with MIT License | 5 votes |
public Object execute(Object[] parameters) { final CosmosParameterAccessor accessor = new CosmosParameterParameterAccessor(method, parameters); final DocumentQuery query = createQuery(accessor); final ResultProcessor processor = method.getResultProcessor().withDynamicProjection(accessor); final String container = ((CosmosEntityMetadata) method.getEntityInformation()).getContainerName(); final CosmosQueryExecution execution = getExecution(accessor); return execution.execute(query, processor.getReturnedType().getDomainType(), container); }
Example #6
Source File: AbstractReactiveCosmosQuery.java From spring-data-cosmosdb with MIT License | 5 votes |
public Object execute(Object[] parameters) { final ReactiveCosmosParameterAccessor accessor = new ReactiveCosmosParameterParameterAccessor(method, parameters); final DocumentQuery query = createQuery(accessor); final ResultProcessor processor = method.getResultProcessor().withDynamicProjection(accessor); final String containerName = ((ReactiveCosmosEntityMetadata) method.getEntityInformation()).getContainerName(); final ReactiveCosmosQueryExecution execution = getExecution(accessor); return execution.execute(query, processor.getReturnedType().getDomainType(), containerName); }
Example #7
Source File: PartTreeFirestoreQueryTests.java From spring-cloud-gcp with Apache License 2.0 | 5 votes |
private PartTreeFirestoreQuery setUpPartTreeFirestoreQuery(String methodName) { Parameters parametersMock = mock(Parameters.class); when(parametersMock.isEmpty()).thenReturn(true); when(this.queryMethod.getParameters()).thenReturn(parametersMock); when(this.queryMethod.getName()).thenReturn(methodName); ReturnedType returnedType = mock(ReturnedType.class); when(returnedType.getDomainType()).thenAnswer(invocation -> User.class); ResultProcessor resultProcessor = mock(ResultProcessor.class); when(resultProcessor.getReturnedType()).thenReturn(returnedType); when(this.queryMethod.getResultProcessor()).thenReturn(resultProcessor); return new PartTreeFirestoreQuery(this.queryMethod, this.firestoreTemplate, new FirestoreMappingContext(), this.classMapper); }
Example #8
Source File: PartTreeEbeanQuery.java From spring-data-ebean with Apache License 2.0 | 5 votes |
protected EbeanQueryCreator createCreator(ParametersParameterAccessor accessor) { EbeanServer ebeanServer = getEbeanServer(); Query ebeanQuery = ebeanServer.createQuery(domainClass); ExpressionList expressionList = ebeanQuery.where(); ParameterMetadataProvider provider = new ParameterMetadataProvider(accessor); ResultProcessor processor = getQueryMethod().getResultProcessor(); return new EbeanQueryCreator(tree, processor.getReturnedType(), expressionList, provider); }
Example #9
Source File: AbstractMybatisQuery.java From spring-data-mybatis with Apache License 2.0 | 5 votes |
@Nullable private Object doExecute(MybatisQueryExecution execution, Object[] values) { Object result = execution.execute(this, values); ParametersParameterAccessor accessor = new ParametersParameterAccessor( method.getParameters(), values); ResultProcessor withDynamicProjection = method.getResultProcessor() .withDynamicProjection(accessor); return withDynamicProjection.processResult(result, new TupleConverter(withDynamicProjection.getReturnedType())); }
Example #10
Source File: KeyValuePartTreeQuery.java From spring-data-keyvalue with Apache License 2.0 | 5 votes |
@Override public Object execute(Object[] parameters) { ParameterAccessor accessor = new ParametersParameterAccessor(getQueryMethod().getParameters(), parameters); KeyValueQuery<?> query = prepareQuery(parameters); ResultProcessor processor = queryMethod.getResultProcessor().withDynamicProjection(accessor); return processor.processResult(doExecute(parameters, query)); }
Example #11
Source File: Neo4jQuerySupport.java From sdn-rx with Apache License 2.0 | 4 votes |
protected final ResultProcessor getResultProcessor(ParameterAccessor parameterAccessor) { return queryMethod.getResultProcessor().withDynamicProjection(parameterAccessor); }
Example #12
Source File: Neo4jQuerySupport.java From sdn-rx with Apache License 2.0 | 4 votes |
protected final List<String> getInputProperties(final ResultProcessor resultProcessor) { ReturnedType returnedType = resultProcessor.getReturnedType(); return returnedType.isProjecting() ? returnedType.getInputProperties() : Collections.emptyList(); }