Affects: All versions
DeferredQueryInvocationHandler should return method.invoke(this.target, args); in an else branch for the unwrap method, otherwise the returned object might not be of the requested type. Consider e.g.
QuerySqmImpl<?> hqlQuery = query.unwrap(QuerySqmImpl.class);
This will fail with a class cast exception when using a proxy with DeferredQueryInvocationHandler.