@Override
 public void preHandle(WebRequest request) throws DataAccessException {
   if (TransactionSynchronizationManager.hasResource(getPersistenceManagerFactory())) {
     // Do not modify the PersistenceManager: just mark the request accordingly.
     String participateAttributeName = getParticipateAttributeName();
     Integer count =
         (Integer) request.getAttribute(participateAttributeName, WebRequest.SCOPE_REQUEST);
     int newCount = (count != null ? count + 1 : 1);
     request.setAttribute(getParticipateAttributeName(), newCount, WebRequest.SCOPE_REQUEST);
   } else {
     logger.debug("Opening JDO PersistenceManager in OpenPersistenceManagerInViewInterceptor");
     PersistenceManager pm =
         PersistenceManagerFactoryUtils.getPersistenceManager(
             getPersistenceManagerFactory(), true);
     TransactionSynchronizationManager.bindResource(
         getPersistenceManagerFactory(), new PersistenceManagerHolder(pm));
   }
 }
 protected PersistenceManager getPersistenceManager() {
   return PersistenceManagerFactoryUtils.getPersistenceManager(pmf, true);
 }