2

I'd like to use the container-managed EntityManager of JPA, but want it to be created from one specific EntityManagerFactory, is it possible to do that? Thanks

Nikolas Charalambidis
  • 40,893
  • 16
  • 117
  • 183
zjffdu
  • 25,496
  • 45
  • 109
  • 159

1 Answers1

0

I think you can use use a container-managed EntityManager of JPA. Maybe you can do this by specifying the persistence unit name when obtaining the EntityManager instance

@PersistenceUnit(unitName = "myPersistenceUnit")
private EntityManagerFactory entityManagerFactory;

public void someMethod() {
    EntityManager entityManager = entityManagerFactory.createEntityManager();
    // Use the entityManager instance to perform JPA operations
    entityManager.close();
}

dincer.unal
  • 67
  • 1
  • 2
  • 13