随后致电JPA在Springboot中失败

发布于 2025-01-29 05:39:47 字数 1040 浏览 7 评论 0原文

我正在尝试执行测试,但只有第一个呼叫Findby()才成功。使用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());

   

随后在同一junit测试方法中调用时,第二个呼叫在junit中失败

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

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)]

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)]

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

拥醉 2025-02-05 05:39:47

看起来像是冬眠中的错误。降级冬眠版本后工作。

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"

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"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文