Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The <code>@Transactional</code> defines the demarcation line. Annotating the class is equivalent with annotating each public method of the class, the line of demarcation is still the method (in your case, the <code>testNumberTransaction()</code>). The commit/rollback decision will be taken at the demarcation point, that is when returning from your test method. Regardless of whether you specify <code>REQUIRES</code> or <code>REQUIRES_NEW</code> propagation, the actual transaction unit is the same, your <code>testNumberTransaction()</code> method so the two <code>service.add(...)</code> calls will always be executed in the same transaction.</p> <p>If your goal is to always roll back your transactions after the test, then simply removing the <code>@Transactional</code> annotation (or putting @nontransactional as you mentioned) should do.</p> <p>If, on the other hand, you want to FORCE a new transaction for each <code>service.add(...)</code> invocation, you could either create a wrapper for your service class where you have an <code>add(...)</code> method that is annotated with @Transactional(propagation = Propagation.REQUIRES_NEW) and call the wrapped <code>service</code> instance <code>add(...)</code> method from there. OR you could add some declarative transaction management in your spring test context that adds transaction advise for your <code>service.add(...)</code> method. Read more in the <a href="http://static.springsource.org/spring/docs/2.5.x/reference/transaction.html#tx-propagation" rel="nofollow">spring documentation</a> on how to add declarative transaction support using the <code>&lt;tx:XXX&gt;</code> tags.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload