Some misunderstanding happened in the parent task.
Reporter wrote in description that exception happens in
method, but it called only when binding parameter to TYPE() expression.
I have the same issue when trying to write a query with optional parameters, e.g.:
So the test case attached to the parent task is incorrect, see the attached modified test case
Exception happens because of this row in the org.hibernate.persister.entity.DiscriminatorType.nullSafeSet(PreparedStatement, Object, int, SessionImplementor) method:
When value is null getClassMetadata() throws NullPointerException.