title: Spring @Transactional on class vs on method
body: <p>I'm using <code>Spring Boot</code> and <code>Spring Data JPA</code>.</p>
  
  <p>Having following class:</p>
  
  <pre><code>import org.springframework.transaction.annotation.Transactional;
  
  @Transactional(propagation = Propagation.REQUIRED)
  public class Foo{
  
      public void bar(){}
  
  }
  </code></pre>
  
  <p>will <code>bar()</code> and any other member method be also transactional?</p>
  
  <p><strong>I also have second question.</strong> On many tutorials people tend to do something like this:</p>
  
  <pre><code>import org.springframework.transaction.annotation.Transactional;
  
  @Transactional(propagation = Propagation.REQUIRED, readOnly = true)
  public class Foo{
  
      @Transactional(propagation = Propagation.REQUIRED, readOnly = false)
      public void bar(){}
  
  }
  </code></pre>
  
  <p>Why? Is using <code>readOnly</code> <code>true</code> and <code>false</code> a it matter of security?</p>