HHH-2188 Query metadata gives NPE for polymorphic queries