Hibernate/JPA CriteriaQuery trim function generate wrong SQL for PostgreSQL

Description

I'm trying to use the Criteria Query trim() function to strip the leading zero's of a field in the database. The relevant part of the criteria query is:

The SQL generated by this snippet is:

This leads to the following exception from Postgres:

PSQLException: ERROR: function pg_catalog.ltrim(character varying, integer) does not exist
Hint: No function matches the given name and argument types. You might need to add explicit type casts.

Expected generated SQL:

Forum discussion: Hibernate/JPA CriteriaQuery trim function wrong SQL Postgres
SO Question: http://stackoverflow.com/questions/41579182/does-hibernate-jpa-criteriaquery-trim-function-generate-the-wrong-sql-for-postgr

Environment

Hibernate ORM 5.2.6
PostgreSQL 9.5.5
Wildfly 9.0.2.Final
Wildfly 10.1.0.Final

Status

Assignee

Andrea Boriero

Reporter

Nico Schlebusch

Fix versions

Labels

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Major
Configure