title: Do I want to minimize the scope of @Transactional?
body: <p>Not sure if 'scope' is the correct term here.</p>
  
  <p>I am using Spring for JPA transaction management (with a Hibernate underneath). My method to preform database transaction is private, but since you can only set @Transactional on a class or on a <a href="http://static.springframework.org/spring/docs/2.0.x/reference/transaction.html" rel="nofollow noreferrer">public method</a></p>
  
  <blockquote>
    <p>Since this mechanism is based on proxies, only 'external' method calls coming in through the proxy will be intercepted.  This means that 'self-invocation', i.e. a method within the target object calling some other method of the target object, won't lead to an actual transaction at runtime even if the invoked method is marked with @Transactional!</p>
  </blockquote>
  
  <p>I have set the public entry point of the class as @Transactional.</p>
  
  <pre><code>@Transactional
  public void run(parameters) {
      //First non-database method, takes a decent amount of time
      Data data = getData();
      //Call to database
      storeData(data);
  }
  
  private storeData(data) {
      em.persist(data);
  }
  </code></pre>
  
  <p>Is this bad practice? Is Spring keep an open transaction for longer then needed here? I was thinking of move the storeData() method to a DAO class and making it public, but as academic point, I wanted to know if refactoring to public would have any performance benefit.</p>