title: EJB/JPA Transaction Boundaries
body: <p>I was reading 
  <a href="https://docs.oracle.com/javaee/6/tutorial/doc/bncij.html" rel="noreferrer">EJB Transaction boundary and Transaction boundary</a></p>
  
  <p>Lets concentrate on <code>RequiresNew Attribute</code>.</p>
  
  <p>Here is the modified diagram from the link</p>
  
  <p><img src="https://i.stack.imgur.com/UYRJh.png" alt="enter image description here"></p>
  
  <p>So let say <code>method-B</code> is annotated with <code>RequiredNew attribute</code>.</p>
  
  <p>so according to theory when <code>method-A</code> calls <code>method-B</code> a new transaction will be start and the already started transaction will be suspended, and when <code>method-B</code> returns the new transaction will be committed.</p>
  
  <hr>
  
  <p>Now consider that in section <code>S1</code> we create a jpa entity using <code>entitymanager.persist()</code> and now we pass this entity to <code>method-B</code> which set the <code>name</code> field of the entity.</p>
  
  <p>Now when we return from <code>method-B</code> how can it <code>commit</code> the transaction as in db, the entity is not being committed by the suspended transaction started by <code>method-A</code> ?</p>
  
  <hr>
  
  <p>PS: Db running in read-committed isolation level.     </p>