Multiple overloads doesn’t work in Hibernate 6

Description

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

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

 

assumption by beikov:

“It seems that the trunc function has multiple overloads but Hibernate 6 only supports the numeric variant right now”

Activity

Show:

Christian Beikov February 2, 2023 at 2:08 PM

Since this just came up again but for the JPA Criteria API, I think we might want to be a bit more lenient on the temporal type there for Oracle:

Helotrix December 21, 2022 at 12:36 PM

Hello Gavin King,

Thank you for your reply. The creation of the bug is based on beikov's initial assessment. It is very gratifying that it is now much less critical.

Gavin King December 21, 2022 at 1:57 AM

So, only because it was very easy to do I just pushed a change that lets you use date_trunc() for this on Oracle. (That’s the more-common name for this SQL function.)

However, this is not a “standard” HQL function, because it’s very hard to implement on lots of databases, so use it at your own risk.

We can now close this issue, IMO.

Gavin King December 20, 2022 at 5:18 PM
Edited

Also change the issue type, because this isn’t a bug, and it certainly isn’t a “Major” bug.

Gavin King December 20, 2022 at 5:18 PM

Can somebody please edit the title of this issue to reflect the actual problem here, something like:

OracleDialect does not register trunc(date) SQL function

And Helotrix in future would you please put just a little bit of thought into the title of your issue reports. Thanks.

Details

Assignee

Reporter

Worked in

Affects versions

Priority

Created December 12, 2022 at 3:03 PM
Updated February 7, 2024 at 10:19 PM