A Cavity-QED Scheme for Generating Long-Lived Maximally Entangled States