title: Spring @Transactional inheritance rules
body: <p>I have a set of <code>@Service</code> beans which inherit core functionality from an abstract class. I marked each of the concrete sub-class services with <code>@Service</code> and <code>@Transactional</code>. The abstract super class contains the public entry point method for each of these services. In other words, I have something similar to the following:</p>
  
  <pre><code>abstract class AbstractService {
  
      public void process() {
          // Do common initialisation code here
          processSpecific();
          // Do common completion code here
      }
  
      abstract protected void processSpecific();
  }
  
  
  @Service @Transactional
  public class FirstSpecificService extends AbstractService {
      protected void processSpecific() {
          // Do specific processing code here
      }
  }
  
  
  @Service @Transactional
  public class SecondSpecificService extends AbstractService {
      protected void processSpecific() {
          // Do different specific processing code here
      }
  }
  </code></pre>
  
  <p>The specific code in each concrete sub-class service makes multiple calls to the DAO layer to make changes to the database, which have <code>REQUIRED</code> as the transactional propagation type.</p>
  
  <p>Now with the services defined as above, I discovered that there was no current transaction inside any of the code of these concrete sub-class services, and each call to the DAO layer was creating a new transaction, doing the changes, committing the transaction and returning.</p>
  
  <p>However, if I annotate the abstract super-class with <code>@Transactional</code>, then a transaction <strong>is</strong> created properly, and the sub-calls to the DAO layer all participate in the current transaction.</p>
  
  <p>So my question is, what are the rules for inheriting the <code>@Transactional</code> behaviour? Why does Spring not use the <code>@Transactional</code> on the concrete sub-class services that it is actually instantiating? Does the <code>@Transactional</code> need to be on the super-class in this case because that is where the public entry-point method is?</p>