title: Where should we use @Transactional and where is Service layer?
body: <p>I have rest style controller in Spring. In controller I have injected dao interfaces. From controller I persist data. In the other words, I have like REST web service. people sends me data, and I persits it.</p>
  
  <pre><code>/**
   * Payment rest controller which receives 
   * JSON of data
   */
  @Controller
  @RequestMapping("/data")
  public class PaymentTransaction {
  
      @Autowired
      private TestDao dao;
  
      @RequestMapping(value = "/test", method = RequestMethod.POST)
      @ResponseBody()
      public String test(HttpServletRequest request) {
  
      ...
  
      }
  </code></pre>
  
  <p>At the moment I have @transaction annotation in Dao classes.  For instance:</p>
  
  <pre><code>    import org.springframework.transaction.annotation.Transactional;
      @Component
      @Transactional
      public interface TestDao {
  
          @Transactional(propagation = Propagation.REQUIRED)
          public void first();
  
      }
  </code></pre>
  
  <p><a href="https://stackoverflow.com/a/23120647/2590960">I have read that this is very bad style. Using this answer</a> at stackoverflow  , here is explain and examples why is this bad - we must not add this annotation in DAO and in controller too. We must add it in service layer. </p>
  
  <p>But I don't understand what is the service layer? Or where is it? I do not have anything like this. 
  where should I write @Transactional annotation?</p>
  
  <p>Best regards,</p>