While upgrading an application to Hibernate ORM 6 my colleagues and I noticed that support for the now()
function was removed from the Postgres dialect. Was this done on purpose or by accident as part of the SQM reworking?
If it wasn’t done on purpose, can it maybe added back to the dialect? I know it’s technically the same as CURRENT_TIMESTAMP
, I just have a soft spot for it. (In that case, I’d be happy to provide a pull request.)
I guess this was removed by accident, so if you want, you can provide a PR with the function registration. Note that the HQL function current_timestamp
maps to localtimestamp
on PostgreSQL, so it is not the same as now
, but usually that detail is negligible.
Thanks for pointing that out. In versions prior to 6, the now()
function was mapped to StandardBasicTypes.TIMESTAMP
. While it might be (a bit) more correct to have it mapped to ZONED_DATE_TIME
since it returns a timestamp with time zone, that’s a change in behaviour. In your opinion, what’s preferable in this situation?
Take a look at org.hibernate.dialect.function.CommonFunctionFactory#nowCurdateCurtime
in the Hibernate ORM source code, which registers that function. We apparently decided to stick to TIMESTAMP
as type for that function.