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
keyParameterNameis validated by classorg.hibernate.query.spi.QueryParameterBindingValidator. ParameterexpectedTypeisjava.lang.Characterand notjava.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.
Comment From: wilkinsona
This looks like a duplicate of https://github.com/spring-projects/spring-boot/issues/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.