Another workaround is to do the cast in the COALESCE call:
Query query = session.createQuery("from Person p where p.name = coalesce(cast( :name as string) , p.name) ");
The problem is only related to PostgreSQL since in works just fine on other DBs. I think it's more an issue with the PostgreSQL driver than Hibernate.