title: How to solve this exception??Caused by: org.hibernate.TransactionException: Transaction not successfully started
body: <p>i am new to hibernate and trying to persist a simple object in database.The data is getting saved in the table but then the following exception is thrown.
  Caused by: org.hibernate.TransactionException: Transaction not successfully started</p>
  
  <p>Here is my code,please help!</p>
  
  <pre><code>    @Transactional
  public void addEmployee(Employee empObj) {
      System.out.println("&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;in DAO");
  
      Transaction tx = null;
      Session session=sessionFactory.getCurrentSession();
  
      try{
      tx=session.beginTransaction();
      session.save(empObj);
      tx.commit();
      }
  
      catch (HibernateException e) {
           if (tx!=null)
               tx.rollback();
           e.printStackTrace(); 
        }
  
  }
  </code></pre>