title: org.hibernate.service.UnknownServiceException: Unknown service requested [org.hibernate.stat.spi.StatisticsImplementor]
body: <p>I got this exception:</p>
  
  <blockquote>
    <p>org.springframework.orm.hibernate4.HibernateSystemException: 
        Unknown service requested [org.hibernate.stat.spi.StatisticsImplementor]; nested exception is org.hibernate.service.UnknownServiceException:
        Unknown service requested [org.hibernate.stat.spi.StatisticsImplementor]</p>
  </blockquote>
  
  <p>When i am using
  <code>session = sessionFactory.openSession();</code> for <code>session</code> .</p>
  
  <p>And i got</p>
  
  <blockquote>
    <p>org.hibernate.TransactionException: nested transactions not supported</p>
  </blockquote>
  
  <p>When i am using <code>session = sessionFactory.getCurrentSession()</code> for <code>session</code>.</p>
  
  <p>what should i do?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>Here is <code>persistUser()</code>in <code>UserServiceImpl</code> class:</p>
  
  <pre><code>@Service
  public class UserServiceImpl implements UserService&lt;User, Integer&gt;, Serializable {
  
  @Autowired
  private UserDao userDao;
  
  @Override
  @Transactional()
  public boolean persistUser(User entity) {
      boolean result;
      userDao.openSessionWithTransaction();
      result = userDao.persist(entity);
      userDao.closeSessionWithTransaction();
      return result;
  }
  ...
  }
  </code></pre>
  
  <p>And here is <code>userDaoImpl</code>:</p>
  
  <pre><code>@Component
  public class UserDaoImpl implements UserDao&lt;User, Integer&gt;, Serializable {
  
  @Autowired
  private SessionFactory sessionFactory;
  
  private Session session;
  private Transaction transaction;
  
  @Override
  public Session openSessionWithTransaction() {
      session = sessionFactory.openSession();
      transaction = session.beginTransaction();
      return session;
  }
  
  @Override
  public void closeSessionWithTransaction() {
      getTransaction().commit();
      sessionFactory.close();
  }
  
  @Override
  public boolean persist(User entity) {
      if (session.save(entity).getClass().getName() != null) {
          return true;
      }
      return false;
  }
  </code></pre>