Skip to content

Repository with 'IgnoreCase': org.springframework.dao.InvalidDataAccessApiUsageException: Parameter value ... did not match expected type [java.lang.Character] #30539

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
marcel-zwernemann opened this issue Apr 5, 2022 · 1 comment
Labels
status: duplicate A duplicate of another issue

Comments

@marcel-zwernemann
Copy link

marcel-zwernemann commented Apr 5, 2022

Bug has occurred since Spring Boot 2.6.6:

A repository with following 'like'-query with IgnoreCase-Ending:

@Repository
public interface SystemParameterRepository extends JpaRepository<SystemParameterEntity, String> {

    List<SystemParameterEntity> findByKeyParameterNameStartsWithIgnoreCase(String keyParameterName);

}

Service executes the query:

  ... 
  repository.findByKeyParameterNameStartsWithIgnoreCase("PREFIX");
  ... 
  • First time, the result is ok.
  • Second time, the parameter keyParameterName is validated by class org.hibernate.query.spi.QueryParameterBindingValidator.
    Parameter expectedType is java.lang.Character and not java.lang.String

Predicate is false on line 81:

        else if (expectedType.isInstance(value)) {
            return true;
        }

Exception is thrown:

org.springframework.dao.InvalidDataAccessApiUsageException: Parameter value [PREFIX%] did not match expected type [java.lang.Character (n/a)]

Without IgnoreCase-suffix it works.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Apr 5, 2022
@marcel-zwernemann marcel-zwernemann changed the title org.springframework.dao.InvalidDataAccessApiUsageException: Parameter value [QUERY%] did not match expected type [java.lang.Character (n/a)] Repository with 'IgnoreCase': org.springframework.dao.InvalidDataAccessApiUsageException: Parameter value ... did not match expected type [java.lang.Character] Apr 5, 2022
@wilkinsona
Copy link
Member

This looks like a duplicate of #30421. If so, downgrading Hibernate should fix the problem while the Hibernate team work on a fix. If that doesn't help, please open a Spring Data JPA issue so that the Spring Data team can investigate.

@wilkinsona wilkinsona added status: duplicate A duplicate of another issue and removed status: waiting-for-triage An issue we've not yet triaged labels Apr 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: duplicate A duplicate of another issue
Projects
None yet
Development

No branches or pull requests

3 participants