Reputation: 23844
This figure is from the book called PRO JPA :
And the text below this figure is:
Figure 2-1 shows that for each persistence unit there is an EntityManagerFactory and that many entity managers can be created from a single EntityManagerFactory.
So the Persistence class has a static method called createEntityManagerFactory, where you provide a String which is the persistenceUnitName.
1) Does that mean that all the EntityManagers are identically same if they are created with the same persistenceUnitName ?
As far as I know, persistenceUnitName is just the persistence.xml we have in the application, which has some configurations like driver name, username, password, and entity class names.
2) Then what is the Persistence Unit seen in this figure? And how does it configure the EntityManagerFactory?
3) And, what is a PersistenceContext, and how does a Persistence Unit create one, and how is it managed by the EntityManager? Is it created as required by the Persistence Unit itself?
Upvotes: 2
Views: 649
Reputation: 8332
See my answer to another of your questions :
https://stackoverflow.com/a/16844778/2087640. If different EntityManager
instances share the same persistence unit
, each one will have its own in-memory representation of the same database schema state.
Upvotes: 2