Add toNamedQuery method