Migration to SpringBoot 3: trunc a date with oracle driver no longer works (hibernate)

I am currently migrating a SpringBoot 2.7 application to SpringBoot 3. The following query is used within a SpringData repository:

@Query("select b from #{#entityName} b where (trunc(b.date) <= trunc(:date))")
List<T> findByDate(LocalDateTime date);

While this works great in SpringBoot 2.7, with SpringBoot 3 the following message is thrown:

org.hibernate.QueryException: Parameter 1 of function trunc() has type NUMERIC, but argument is of type java.time.LocalDateTime

Unfortunately, a simple migration to datetrunc was unsuccessful:

Error Msg = ORA-00904: “DATETRUNC”: ungültige ID

Does anyone have a solution for this?

Best regards

Hey there. It seems that the trunc function has multiple overloads but Hibernate 6 only supports the numeric variant right now. Please create a JIRA issue for this bug.

Thank you for your prompt reply. Issue was opened under HHH-15855.

1 Like