Gavin King (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
) *created* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiY2QxMTRjYjQy...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-16035?atlOrigin=eyJpIjoiY2QxMT...
) HHH-16035 (
https://hibernate.atlassian.net/browse/HHH-16035?atlOrigin=eyJpIjoiY2QxMT...
) Duration literals and 'by' are almost completely broken (
https://hibernate.atlassian.net/browse/HHH-16035?atlOrigin=eyJpIjoiY2QxMT...
)
Issue Type: Bug Assignee: Unassigned Components: hibernate-core Created: 13/Jan/2023 00:23
AM Priority: Major Reporter: Gavin King (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
)
There is a cluster of bugs around the handling of HQL durations, with literals like 3 day
or 5 second and conversions to integer like e.theDuration by second or e.theDuration by
day.
* On h2, where the storage type for Duration was changed from numeric to interval second ,
literal durations simply don’t work at all, except in arithmetic expressions, since they
need to be rendered as interval ‘3' DAY or interval ‘5' second and instead they’re
just rendered as an integer.
* But worse, literal durations also seem to be broken on Postgres, where the storage type
is numeric(21,0) , apparently as a side effect of the introduction of
PostgreSQLIntervalSecondJdbcType.
* On databases where getFractionalSecondPrecisionInNanos()!=1 , conversion of a duration
to integer using the by operator is completely broken since the value of
getFractionalSecondPrecisionInNanos() is simply ignored. (I’m pretty sure this used to
work, so I’m not sure what happened here.)
* Apparently DB2 doesn’t like {{ {d ‘1974-03-23'}
+(2) days}} so we should see if there’s a better way to handle datetime literals on DB2.
(This is a very minor issue.)
The ironic thing here is that stuff is most broken on Postgres, which is the database we
usually test the best.
By the way, I question the value of PostgreSQLIntervalSecondJdbcType. What do we even need
this for, if we don’t even use interval to store Duration}}s on Postgres? (It looks like
we can’t, since {{interval doesn’t have nanosecond precision.) And the implementation is
awful reflection-based stuff that probably doesn’t work in Quarkus. I guess I would be
inclined to just delete this ugly thing.
(
https://hibernate.atlassian.net/browse/HHH-16035#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-16035#add-comment?atlOrigin=ey...
)
Get Jira notifications on your phone! Download the Jira Cloud app for Android (
https://play.google.com/store/apps/details?id=com.atlassian.android.jira....
) or iOS (
https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=Em...
) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100214- sha1:b03f6a4 )