title: Spring transactions: Method with requires_new called from a method with requires
body: <p>I would like to understand when exactly commit happens and when exactly rollback happens in case of nested transaction with different isolation levels to calling and called methods,</p>
  
  <p>For example, I have two spring services and i'm calling method2 of service2 from method1 of service1.</p>
  
  <p>Method1 is having REQUIRED transaction scope and Method2 is having REQUIRES_NEW transaction scope as shown in the program below.</p>
  
  <pre><code>Service1 {
  
   @Transactional(propagation = Propagation.REQUIRED)
  method1()
  {
      for(int i=0; i&lt;10; i++){
          service2.method2();
      }
  
      // Some more code which takes some time to process
  }
  
  }
  
  
  Service2 {
   @Transactional(propagation = Propagation.REQUIRES_NEW)
   method2()
   {
      //Save some information to DB
      // Save an object using JPA
   }
  }
  </code></pre>
  
  <p>Now my question is,
  As i understand REQUIRES_NEW will start a new transaction, But will it commit immediately on existing method2 or will the spring waits till method1 is completed and then commits?</p>
  
  <p>I'm interested in at what point of time commit happens and row lock in DB gets released which is persisted in method2.</p>
  
  <p>Note: Here i have placed both methods in different services so that spring can achieve nested transaction.</p>
  
  <p>Thanks in Advance,</p>
  
  <p>Vali</p>