[dispatcherServlet] in context with path [] threw exception [Request processing failed: org.springframework.dao.InvalidDataAccessApiUsageException: Can't compare test expression of type [Facility] with element of type [basicType@4(java.lang.Integer,4)]] with root cause
java.lang.IllegalArgumentException: Can't compare test expression of type [Facility] with element of type [basicType@4(java.lang.Integer,4)]
at org.hibernate.query.sqm.internal.SqmCriteriaNodeBuilder.assertComparable(SqmCriteriaNodeBuilder.java:2098)
at org.hibernate.query.sqm.internal.SqmCriteriaNodeBuilder.equal(SqmCriteriaNodeBuilder.java:2121)
at org.hibernate.query.sqm.internal.SqmCriteriaNodeBuilder.equal(SqmCriteriaNodeBuilder.java:182)
at com.freit.medicalservice.repository.specification.PatientSpecification.lambda$facilityIdEqual$2a154287$1(PatientSpecification.java:139)
at org.springframework.data.jpa.domain.SpecificationComposition.toPredicate(SpecificationComposition.java:62)
at org.springframework.data.jpa.domain.SpecificationComposition.lambda$composed$e1dcbe07$1(SpecificationComposition.java:49)
at org.springframework.data.jpa.domain.SpecificationComposition.toPredicate(SpecificationComposition.java:62)
Run Code Online (Sandbox Code Playgroud)
在我从 spring 及其相关包(包括 JPA、Hibernate)从版本 5 迁移到版本 6 后,我在 JPA 规范上遇到了这个愚蠢的错误,这两天一直困扰着我。
我遇到错误的线路;
public static Specification<Patient> facilityIdEqual(Integer facilityId) {
return (root, query, builder) -> {
if (facilityId != …Run Code Online (Sandbox Code Playgroud) hibernate jpa spring-data-jpa spring-boot entity-framework-migrations