Skip to content

The parameter in Criteria#assertNoBlankInWildcardQuery is set incorrectly #2743

Closed
@mawen12

Description

@mawen12

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions