A generating functional approach to the Hubbard model