Subsequent calls to JPA failing in SpringBoot

Viewed 77

I'm trying to execute tests but only the first call to findBy() is successful. Running with Spring Boot v2.6.7, Spring v5.3.19, hibernate jar = 5.6.8.

   Application application = Application.builder()
                .appName("APP1")
                .productName("PRD1")
                .build();
        
   applicationDao.save(application);

   Application app1 = applicationDao.findByAppNameIgnoreCaseAndProductNameIgnoreCaseContaining("APP1","PRD");
        assertEquals("APP1", app1.getAppName());

   

The second calls fails in JUnit when called subsequently in the same JUnit test method

   Application app2= applicationDao.findByAppNameIgnoreCaseAndProductNameIgnoreCaseContaining("APP1","PRD");
        assertEquals("APP1", app2.getAppName());

Error:

org.springframework.dao.InvalidDataAccessApiUsageException: Parameter value [APP1] did not match expected type [java.lang.Character (n/a)]; nested exception is java.lang.IllegalArgumentException: Parameter value [APP1] did not match expected type [java.lang.Character (n/a)]
1 Answers

Looks like a bug in hibernate. Worked after downgrading hibernate version.

implementation ('org.springframework.boot:spring-boot-starter-data-jpa'){
    exclude group: "org.hibernate", module: "hibernate-core"
}
implementation "org.hibernate:hibernate-core:5.6.5.Final"
Related