Detect custom type automatically in native postgres sql query

Description

If jpa native query returns a custom db type (such as postgres "tsvector"), the jdbc type is OTHER(1111).
To correctly map the result, a custom type class must be provided to SQLQuery.addScalar(String columnAlias, Type type).
Without the above scalar type registration, query fails with a "org.hibernate.MappingException: No Dialect mapping for JDBC type: 1111", even if the custom type was registered in dialect via TypeContributions.contributeType.

It would be nice if the custom type was registered with a sql type (OTHER in this case), to check the PGObject and try to match a custom registered type.

This issue affets QueryDSL native jpa query functionality, as it internally uses SQLQuery.addScalar(String columnAlias), without any knowledge of the hibernate custom type.

Environment

PostgreSQL 9.6 (PostgreSQL Native Driver 9.4.1211), QueryDSL 4.1,4, Spring Boot 1.4.0

Assignee

Unassigned

Reporter

Alex CD

Fix versions

None

Labels

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Minor
Configure