Code duplicates in EntityManagerImpl