title: Exception Handling with Spring's @Transactional
body: <p>I'm developing a web app with Spring MVC and hibernate for persistence.
  Given my DAO where GenericDao has a SessionFactory member attribute:</p>
  
  <pre><code>@Repository
  public class Dao extends GenericDao {
      public void save(Object o) {
          getCurrentSession().save(o);
      }
  }
  </code></pre>
  
  <p>And a Service class</p>
  
  <pre><code>@Service
  public class MyService {
      @Autowired
      Dao dao;
  
      @Transactional
      public void save(Object o) {
          dao.save(o);
      }
  }
  </code></pre>
  
  <p>I want to inform my user if a persistence exception occurs (constraint, duplicate, etc). As far as I know, the <code>@Transactional</code> annotation only works if the exception bubbles up and the transaction manager rolls back so I shouldn't be handling the exception in that method. Where and how should I catch an exception that would've happened in the DAO so that I can present it to my user, either directly or wrapped in my own exception? </p>
  
  <p>I want to use spring's transaction support.</p>