Closed spring-projects-issues closed 4 years ago
Carlos Pereda commented
Hi,
i've seen the same problem calculating quotation when upgrading StringQuery class to use SpelExtractor from data commons in DATAJPA-1267 - Using SpEL infrastructure from commons. Jens Schauder* 17/05/18 10:51.
It looks like in SpelExtractor constructor final QuotationMap attribute is assigned from original query string and not with new resultQuery calculated, making isQuoted method failing, so the bug could be in spring data commons.
this is the code i'm referring
SpelExtractor(String query) {
Assert.notNull(query, "Query must not be null");
Map<String, String> expressions = new HashMap<>();
Matcher matcher = SPEL_PATTERN.matcher(query);
StringBuilder resultQuery = new StringBuilder();
QuotationMap quotedAreas = new QuotationMap(query);
int expressionCounter = 0;
int matchedUntil = 0;
while (matcher.find()) {
....
}
resultQuery.append(query.substring(matchedUntil));
this.expressions = Collections.unmodifiableMap(expressions);
this.query = resultQuery.toString();
this.quotations = quotedAreas; ==> maybe something as new QuotationMap(this.query);
}
Hope this can help to fix it soon.
Thanks!
Mark Paluch commented
Thanks for report. That issue is going to be fixed with DATACMNS-1683
Linh Nguyen Dinh opened DATAJPA-1471 and commented
I've used @Query annotation in Spring Data JPA to execute JPQL. Here is my JPQL:
But I got an exception when Spring jpa parse my JPQL.
I debug and figure out that the
org.springframework.data.jpa.repository.query.StringQuery.ParameterBindingParser#parseParameterBindingsOfQueryIntoBindingsAndReturnCleanedQuery
Because of
The spelExtractor#isQuoted is used new QuotationMap() to check index of Quotation to ignore the parser. But the matcher is PARAMETER_BINDING_PATTERN.matcher()
and and is not the same.
in my case, the *SpelExtractor* is
The QuotationMap has a Range 365-366 (range of double quote character at {#searchForm.address} = '')
And the *matcher.start()* at
is
*366.*
That why the
ParameterBindingParser
has ignored the
Affects: 2.1.3 (Lovelace SR3)
Issue Links:
1 votes, 3 watchers