I have many persistence units in my persistence.xml, one by postgreSQL schema.

I instantiate my EntityManager whenever I need by creating EntityManagerFactory dynamically :

```
EntityManagerFactory emf = Persistence.createEntityManagerFactory(schemaToChoose);
EntityManager em = emf.createEntityManager();

```

and it works fine. But thus, I don't use container injection.

Now, I wonder if it doesn't cost too much resources by this way ?

I don't probably understand well JPA cache but I believe that entities are stored inside em cache and inside emf cache, there are 2 levels. So when I instantiate em and emf each time I probably loose JPA cache and thus, I recreate it each time too.

I have 2 questions : could instantiate each time emf and em impact perfomances ? Should I inject as many em that I have schemas instead to keep cache ?

Thank you