title: Nested transactions in spring
body: <p>We're building a new application in Spring MVC with Hibernate as persistence solution.
  There 're 2 solutions to approach the data layer:</p>
  
  <p>1) In some cases the controller invokes the DAO layer directly. This is done because no business checks need to be performed. So we're bypassing the Service layer for such cases.
  Implementing a Service layer for this would turn up in just delegating methods to the DAO layer.<br><br>
  So we're doing the following: Controller -> DAO</p>
  
  <p>2) In other cases we do need some business checks. For this, we use the conventional way:<br>
  Controller -> Service -> DAO</p>
  
  <p>In Spring we need to demarcate a Transaction, therefore we put @Transaction annotation on all DAO methods. This works fine doing the Controller -> DAO way. But if we're doing the Controller -> Service -> DAO way, we also need to put a @Transaction annotation on the service method.</p>
  
  <p>This means that we're having nested transactions in some cases.
  Is this a good approach?
  Do we need to create a new transaction (REQUIRES_NEW) on all DAO methods or rather use the existing transaction (REQUIRED) if one exists?</p>
  
  <p>Can someone enlighten me on this?</p>