implement equals and hashCode for the different Query classes