With Hibernate ORM 4.2.5 the NPE in CastFunction.render() is gone, at least when using the criteria API and Postgresql Dialect. (didn't check JPQL though)