HHH-9291

This changes the order of the parameter values for a with clause as they are added to the query so that they match the order of the joins that were previously generated.