Hibernate validation error when upgraded Spring boot version

Spring boot version: 3.4.1
Hibernate version: 6.6.4.Final

Getting below error when we are comparing date with string

payment_date = '2025-02-19'

Caused by: org.hibernate.query.SemanticException: Cannot compare left expression of type 'java.sql.Date' with right expression of type 'java.lang.String'
  at org.hibernate.query.sqm.internal.TypecheckUtil.assertComparable(TypecheckUtil.java:406)
  at org.hibernate.query.sqm.tree.predicate.SqmComparisonPredicate.<init>(SqmComparisonPredicate.java:46)
  at org.hibernate.query.sqm.tree.predicate.SqmComparisonPredicate.<init>(SqmComparisonPredicate.java:32)
  at org.hibernate.query.hql.internal.SemanticQueryBuilder.createComparisonPredicate(SemanticQueryBuilder.java:2567)
  at org.hibernate.query.hql.internal.SemanticQueryBuilder.visitComparisonPredicate(SemanticQueryBuilder.java:2509)
  at org.hibernate.query.hql.internal.SemanticQueryBuilder.visitComparisonPredicate(SemanticQueryBuilder.java:277)

Earlier, with spring boot version 2.6.x it was working.

Hello @NIKHIL_PATE, Hibernate 6.2 introduced early query path comparison typechecks to ensure the correctness of queries. While using a string when comparing a date value works on some databases, that is not the case for all of them, so Hibernate reports this as an error before executing the query.

You should use something like:

payment_date = date '2025-02-19'

Find more details in this chapter of the 6.2 migration guide.

Thanks @mbladel for quick resolution.