Closed
Description
Criteria#assertNoBlankInWildcardQuery
used to check if searchString
contains blank.
public Criteria startsWith(String s) {
Assert.notNull(s, "s may not be null");
// it should be (s, false, true)
assertNoBlankInWildcardQuery(s, true, false);
queryCriteriaEntries.add(new CriteriaEntry(OperationKey.STARTS_WITH, s));
return this;
}
private void assertNoBlankInWildcardQuery(String searchString, boolean leadingWildcard, boolean trailingWildcard) {
if (searchString.contains(CRITERIA_VALUE_SEPARATOR)) {
throw new InvalidDataAccessApiUsageException("Cannot constructQuery '" + (leadingWildcard ? "*" : "") + '"'+ searchString + '"' + (trailingWildcard ? "*" : "") + "'. Use expression or multiple clauses instead.");
}
}
if call the method startsWith("a c")
, it will throw InvalidDataAccessApiUsageException with message Cannot constructQuery '*"a c"'. Use expression or multiple clauses instead.
However, the message should be '"a c"*'
to match the startsWith
method.