have updated my spring boot project, following are the updated dependencies
- Java 11 - Java 21
- Springboot 2.7.8 to 3.2.3
- Servlet 6.0
- JPA 3.1
- Hibernate 6
- Spring security 6
I am facing below issue:
org.hibernate.query.SemanticException: Cannot compare left expression of type 'com.example.demo.CompositeEntity$Another' with right expression of type 'java.lang.Long'
at org.hibernate.query.sqm.internal.TypecheckUtil.assertComparable(TypecheckUtil.java:358)
at org.hibernate.query.sqm.tree.predicate.SqmComparisonPredicate.<init>(SqmComparisonPredicate.java:48)
at org.hibernate.query.sqm.tree.predicate.SqmComparisonPredicate.<init>(SqmComparisonPredicate.java:34)
at org.hibernate.query.sqm.internal.SqmCriteriaNodeBuilder.equal(SqmCriteriaNodeBuilder.java:2132)
at org.hibernate.query.sqm.internal.SqmCriteriaNodeBuilder.equal(SqmCriteriaNodeBuilder.java:192)
at com.example.demo.LocalDataRepository.grouped(LocalDataRepository.java:29)
at com.example.demo.LocalDataRepositoryIntegrationTest.testShouldFindAnotherById(LocalDataRepositoryIntegrationTest.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
In prior version with Spring Boot 3.2.3 it was working fine.
I have created one demo project for same issue which is in my project.
Comment From: wilkinsona
Thanks for the report. I believe that this is a bug in your query building that's now being caught due to some improvements in Hibernate. You're asking it to compare a long and a CompositeEntity$Another which doesn't really make sense. Please see https://discourse.hibernate.org/t/upgrade-to-6-3-rc1-cannot-compare-left-expression-of-type-java-sql-timestamp-with-right-expression-of-type-com-model-entity-impl-user/8034 for some other examples and discussion.