Hi. I'm trying to make a formula to select a user-friendly name of the user profile.
Code:
@Formula("COALESCE(NULLIF(TRIM(BOTH FROM CONCAT(sp.firstname, ' ', sp.lastname)), ''), p.shortname, to_char(p.id, 'FM9999999999999999')) " +
"FROM socialprofile AS sp " +
"JOIN profile AS p ON sp.id=p.id")
public String getUserFriendlyName() {
return super.getUserFriendlyName();
}
The result is:
"org.hibernate.HibernateException: Unexpected number of trim function operands : 10"
but there is only 3 arguments: BOTH, FROM and result of CONCAT. Is there any workaround of this issue?
Upd: DB is PostgreSQL, Hibernate version is 4.2.1