title: Manual rollback Spring MVC + Hibernate
body: <p>I am using Spring <strong>MVC + Hibernate</strong></p>
  
  <pre><code>//Class for Generic Methods for **save and update** 
  
  @Service("PersistenceTemplate")
  @Transactional
  public class PersistenceTemplate {
  
  @Resource(name = "sessionFactory")
  private SessionFactory sessionFactory;
  
  // SAVE 
  public &lt;T&gt; long save(T entity) throws DataAccessException {
      Session session = sessionFactory.getCurrentSession();
      long getGenVal=(Long) session.save(entity);
      return getGenVal;
  }
  //UPDATE
  public &lt;T&gt; void update(T entity) throws DataAccessException {
      sessionFactory.getCurrentSession().update(entity);
  }
  </code></pre>
  
  <p>}</p>
  
  <p><strong>AT Controller</strong> </p>
  
  <pre><code>@Resource(name = "PersistenceTemplate")
  private PersistenceTemplate pt;
  long result=pt.save(receiveTrxObj1);
  pt.Update(receiveTrxObj2);
  </code></pre>
  
  <p><strong>Problem statement</strong> </p>
  
  <p>How to roll back save statement if Update fails to update the entity in database ? </p>