# Hibernate validation error when upgraded Spring boot version

**URL:** <https://discourse.hibernate.org/t/hibernate-validation-error-when-upgraded-spring-boot-version/10997>\
**Category:** Hibernate ORM\
**Created:** [February 5, 2025, 12:04pm UTC](https://discourse.hibernate.org/t/hibernate-validation-error-when-upgraded-spring-boot-version/10997 "2025-02-05T12:04:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![NIKHIL\_PATE](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/nikhil_pate/32/3819_2.png) [@NIKHIL\_PATE](https://discourse.hibernate.org/u/NIKHIL_PATE)\
**Post date:** [February 5, 2025, 12:04pm UTC](https://discourse.hibernate.org/t/hibernate-validation-error-when-upgraded-spring-boot-version/10997/1 "2025-02-05T12:04:20Z")

</div>

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'`

```auto
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.

---

<div class="post-metadata">

**Author:** ![mbladel](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/mbladel/32/2128_2.png) [@mbladel](https://discourse.hibernate.org/u/mbladel)\
**Post date:** [February 5, 2025, 1:13pm UTC](https://discourse.hibernate.org/t/hibernate-validation-error-when-upgraded-spring-boot-version/10997/2 "2025-02-05T13:13:21Z")

</div>

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:

```auto
payment_date = date '2025-02-19'

```

Find more details in [this chapter](https://docs.jboss.org/hibernate/orm/6.2/migration-guide/migration-guide.html#query-path-comparison) of the 6.2 migration guide.

---

<div class="post-metadata">

**Author:** ![NIKHIL\_PATE](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/nikhil_pate/32/3819_2.png) [@NIKHIL\_PATE](https://discourse.hibernate.org/u/NIKHIL_PATE)\
**Post date:** [February 6, 2025, 4:18am UTC](https://discourse.hibernate.org/t/hibernate-validation-error-when-upgraded-spring-boot-version/10997/3 "2025-02-06T04:18:57Z")

</div>

Thanks @mbladel for quick resolution.
