Code example for EntityManagerHolder

Methods: getEntityManager

0
	public void afterCompletion(WebRequest request, Exception ex) throws DataAccessException { 
		if (!decrementParticipateCount(request)) { 
			EntityManagerHolder emHolder = (EntityManagerHolder) 
					TransactionSynchronizationManager.unbindResource(getEntityManagerFactory()); 
			logger.debug("Closing JPA EntityManager in OpenEntityManagerInViewInterceptor"); 
			EntityManagerFactoryUtils.closeEntityManager(emHolder.getEntityManager()); 
		} 
	} 
 
	private boolean decrementParticipateCount(WebRequest request) { 
		String participateAttributeName = getParticipateAttributeName(); 
		Integer count = (Integer) request.getAttribute(participateAttributeName, WebRequest.SCOPE_REQUEST); 
		if (count == null) { 
			return false; 
		} 
		// Do not modify the Session: just clear the marker. 
		if (count > 1) { 
			request.setAttribute(participateAttributeName, count - 1, WebRequest.SCOPE_REQUEST); 
		} 
		else {