PostgreSQL function "age" cannot be used in HQL queries

Description

In PostgreSQL81Dialect, the function “age“ is registered as follows:

The documentation for StandardSQLFunction states that “Using this form, the return type is considered non-static and assumed to be the type of the first argument.“

The PostgreSQL documentation states that the return type for this function is an interval while taking one or two timestamps.

When using the function in an HQL,

an exception is thrown:

org.hibernate.QueryException: No data type for node: org.hibernate.hql.internal.ast.tree.MethodNode
+-[METHOD_CALL] MethodNode: 'function (age)'
| +-[METHOD_NAME] IdentNode: 'age' {originalText=age}
| \-[EXPR_LIST] SqlNode: 'exprList'
| +-[NAMED_PARAM] ParameterNode: '?' {name=testDate, expectedType=null}

Setting the parameter as string

gives the same exception.

It seems that it is not possible using Postgres’s age function with the current definition.

Providing a custom dialect,

the problem is solved.

Environment

OpenJDK Runtime Environment (build 1.8.0_242-8u242-b08-0ubuntu3~18.04-b08)
OpenJDK 64-Bit Server VM (build 25.242-b08, mixed mode)
Ubuntu 18.04 LTS
PostgreSQL 10+190ubuntu0.1

Assignee

Unassigned

Reporter

lukas.schmidt

Fix versions

None

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Major
Configure