org.springframework.data.repository.query.SpelQueryContext.SpelExtractor Java Examples
The following examples show how to use
org.springframework.data.repository.query.SpelQueryContext.SpelExtractor.
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: StringQuery.java From spring-data-mybatis with Apache License 2.0 | 6 votes |
private static SpelExtractor createSpelExtractor(String queryWithSpel, boolean parametersShouldBeAccessedByIndex, int greatestParameterIndex) { /* * If parameters need to be bound by index, we bind the synthetic expression * parameters starting from position of the greatest discovered index * parameter in order to not mix-up with the actual parameter indices. */ int expressionParameterIndex = parametersShouldBeAccessedByIndex ? greatestParameterIndex : 0; BiFunction<Integer, String, String> indexToParameterName = parametersShouldBeAccessedByIndex ? (index, expression) -> String .valueOf(index + expressionParameterIndex + 1) : (index, expression) -> EXPRESSION_PARAMETER_PREFIX + (index + 1); String fixedPrefix = parametersShouldBeAccessedByIndex ? "?" : ":"; BiFunction<String, String, String> parameterNameToReplacement = (prefix, name) -> fixedPrefix + name; return SpelQueryContext.of(indexToParameterName, parameterNameToReplacement) .parse(queryWithSpel); }
Example #2
Source File: StringQuery.java From ignite with Apache License 2.0 | 6 votes |
/** */ private static SpelExtractor createSpelExtractor(String queryWithSpel, boolean parametersShouldBeAccessedByIndex, int greatestParameterIndex) { /* * If parameters need to be bound by index, we bind the synthetic expression parameters starting from * position of the greatest discovered index parameter in order to * not mix-up with the actual parameter indices. */ int expressionParameterIndex = parametersShouldBeAccessedByIndex ? greatestParameterIndex : 0; BiFunction<Integer, String, String> indexToParameterName = parametersShouldBeAccessedByIndex ? (index, expression) -> String.valueOf( index + expressionParameterIndex + 1) : (index, expression) -> EXPRESSION_PARAMETER_PREFIX + (index + 1); String fixedPrefix = parametersShouldBeAccessedByIndex ? "?" : ":"; BiFunction<String, String, String> parameterNameToReplacement = (prefix, name) -> fixedPrefix + name; return SpelQueryContext.of(indexToParameterName, parameterNameToReplacement).parse(queryWithSpel); }
Example #3
Source File: ReactiveStringBasedNeo4jQuery.java From sdn-rx with Apache License 2.0 | 5 votes |
private ReactiveStringBasedNeo4jQuery(ReactiveNeo4jOperations neo4jOperations, Neo4jMappingContext mappingContext, QueryMethodEvaluationContextProvider evaluationContextProvider, Neo4jQueryMethod queryMethod, String cypherTemplate, Neo4jQueryType queryType) { super(neo4jOperations, mappingContext, queryMethod, queryType); SpelExtractor spelExtractor = SPEL_QUERY_CONTEXT.parse(cypherTemplate); this.spelEvaluator = new SpelEvaluator(evaluationContextProvider, queryMethod.getParameters(), spelExtractor); this.cypherQuery = spelExtractor.getQueryString(); }
Example #4
Source File: StringBasedNeo4jQuery.java From sdn-rx with Apache License 2.0 | 5 votes |
private StringBasedNeo4jQuery(Neo4jOperations neo4jOperations, Neo4jMappingContext mappingContext, QueryMethodEvaluationContextProvider evaluationContextProvider, Neo4jQueryMethod queryMethod, String cypherTemplate, Neo4jQueryType queryType) { super(neo4jOperations, mappingContext, queryMethod, queryType); SpelExtractor spelExtractor = SPEL_QUERY_CONTEXT.parse(cypherTemplate); this.spelEvaluator = new SpelEvaluator(evaluationContextProvider, queryMethod.getParameters(), spelExtractor); this.cypherQuery = spelExtractor.getQueryString(); }