public EntityManager getEntityManager(String unitName, HibernateProxy proxy, Transaction transaction) throws EntityManagerCreationException { // Note this method is thread-safe as a Transaction is only visible to a single thread at time. Key key = new Key(transaction, unitName); EntityManager em = cache.get(key); if (em == null) { // no entity manager for the persistence unit associated with the transaction EntityManagerFactory emf = emfCache.get(unitName); if (emf == null) { throw new EntityManagerCreationException("No EntityManagerFactory found for persistence unit: " + unitName); } em = emf.createEntityManager(); // don't synchronize on the transaction since it can assume to be bound to a thread at this point registerTransactionScopedSync(proxy, key); cache.put(key, em); } return em; }
public EntityManager getEntityManager(String unitName, HibernateProxy proxy, Transaction transaction) throws Fabric3Exception { // Note this method is thread-safe as a Transaction is only visible to a single thread at time. Key key = new Key(transaction, unitName); EntityManager em = cache.get(key); if (em == null) { // no entity manager for the persistence unit associated with the transaction EntityManagerFactory emf = emfCache.get(unitName); if (emf == null) { throw new Fabric3Exception("No EntityManagerFactory found for persistence unit: " + unitName); } em = emf.createEntityManager(); // don't synchronize on the transaction since it can assume to be bound to a thread at this point registerTransactionScopedSync(proxy, key); cache.put(key, em); } return em; }
public EntityManager getEntityManager(String unitName, HibernateProxy proxy, Transaction transaction) throws Fabric3Exception { // Note this method is thread-safe as a Transaction is only visible to a single thread at time. Key key = new Key(transaction, unitName); EntityManager em = cache.get(key); if (em == null) { // no entity manager for the persistence unit associated with the transaction EntityManagerFactory emf = emfCache.get(unitName); if (emf == null) { throw new Fabric3Exception("No EntityManagerFactory found for persistence unit: " + unitName); } em = emf.createEntityManager(); // don't synchronize on the transaction since it can assume to be bound to a thread at this point registerTransactionScopedSync(proxy, key); cache.put(key, em); } return em; }