-
Type:
Bug
-
Status: Resolved
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 5.4, 5.3.8
-
Fix Version/s: 5.4.1
-
Component/s: tapestry-jpa
-
Labels:None
On application start if more than one thread needs an entity manager more than one instance of EntityManagerFactory may be created.
This is undesirable, because EMF may use a connection pool and creating more than one instance will lead to too many open database connections.
EntityManagerSourceImpl.java:
public EntityManagerFactory getEntityManagerFactory(final String persistenceUnitName) { EntityManagerFactory emf = entityManagerFactories.get(persistenceUnitName); if (emf == null) { emf = createEntityManagerFactory(persistenceUnitName); entityManagerFactories.put(persistenceUnitName, emf); } return emf; }
Above code needs some synchronization.