changed session factory to entity manager factory