Note that there are some explanatory texts on larger screens.

plurals
  1. POSpring @transactional behaving strangely with mode=aspectj
    primarykey
    data
    text
    <p>I've been trying to get Spring transactions working properly in my application for days, and now I have nowhere to turn but to the community. Thanks in advance for your help.</p> <p>My application has specific requirements where I need to annotate a protected overridden method with @Transactional and call this method from the abstract parent class. From what I've read, I can not use proxies, and must use mode=aspectj.</p> <p>First, some configuration:</p> <pre><code>&lt;bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"&gt; &lt;property name="dataSource" ref="dataSource" /&gt; &lt;/bean&gt; &lt;tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="false" mode="aspectj" /&gt; &lt;context:load-time-weaver /&gt; &lt;bean name="ID_DataAccessor" class="dal.DataAccessor"&gt; &lt;constructor-arg ref="dataSource" /&gt; &lt;/bean&gt; &lt;bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"&gt; &lt;property name="driverClassName" value="com.mysql.jdbc.Driver" /&gt; &lt;property name="url" value="jdbc:mysql://localhost" /&gt; ..... &lt;property name="defaultAutoCommit" value="true" /&gt; &lt;/bean&gt; </code></pre> <p>If I use the @Transactional annotation on a method in ID_DataAccessor, then the connection is transactional (<code>DataSourceUtils.isConnectionTransactional(c, dataSource) == true</code>). This is useless to me though, because the transaction commits as soon as the method is completed. When I use @Trasnactional on a method that calls a method in DataAccessor, the connection aquired in DataAccessor (from <code>DataSourceUtils.getConnection(dataSource)</code>) is NOT transactional. Additionally, I put a breakpoint in DataSourceTransactionManager.doGetTransaction(), and this is only called if the @Transactional annotation is directly on the method acquiring the connection. Forgive me for overloading the terminology, but it appears that the @Transactional annotation does not propagate up the stack. </p> <p>I'm completely baffled. Please help! :)</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.
 

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