Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Hm, i got it to work.</p> <ol> <li>To test Transactions: a simple <code>em.flush()</code> is all i need (thanks to @TaoufikMohdit for the idea). If there is no transaction, <code>flush()</code> throws a <code>TransactionRequiredException</code>!</li> <li><p><code>@Transactional</code> is for Spring-Managed-Beans only. So i create a Service:</p> <pre><code>@Service public class BasicTransactionalService { @PersistenceContext HibernateEntityManager em; @Transactional public void testFlushInTransactional() { em.flush(); } @Deprecated public void testFlushOutsideTransactional() { em.flush(); } @Transactional public void testFlushSubroutineTransactional() { testFlushOutsideTransactional(); } } </code></pre></li> <li><p>I changed the Tests to:</p> <pre><code>@Autowired BasicTransactionalService bean; @Test public void testTransactionIsolation() { bean.testFlushInTransactional(); } @Test(expected = TransactionRequiredException.class) @SuppressWarnings("deprecation") public void testThrowsTransactionRequiredException() { bean.testFlushOutsideTransactional(); } @Test public void testTransactionalSubroutine(){ bean.testFlushSubroutineTransactional(); } </code></pre></li> </ol> <p>Now it works fine.</p> <p>BTW This is my <code>app-config.xml</code></p> <pre><code>&lt;beans&gt; &lt;bean class="BasicTransactionalService" /&gt; &lt;bean class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean" /&gt; &lt;bean class="org.springframework.orm.jpa.JpaTransactionManager" /&gt; &lt;tx:annotation-driven /&gt; &lt;beans&gt; </code></pre>
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    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