Spring MVC 4 service @tTransactional doesn't work
<p><code>1. Spring MVC application-context.xml</code></p>

<pre><code>&lt;tx:annotation-driven/&gt;

    &lt;bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"&gt;
        &lt;property name="driverClassName" value="com.mysql.jdbc.Driver"/&gt;
        &lt;property name="username" value="test"/&gt;
        &lt;property name="password" value="test"/&gt;
        &lt;property name="url" value="jdbc:mysql://localhost:13306/test"/&gt;
    &lt;/bean&gt;

    &lt;bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"&gt;
        &lt;property name="dataSource" ref="dataSource"/&gt;
    &lt;/bean&gt;
</code></pre>

<p><code>2. Service impl class</code></p>

<pre><code>@Override
@Transactional
public void deleteCommentAndFiles(int commentId) {
    int deletedCommentCount = commentDAO.deleteComment(commentId);
    int deletedFileCount = fileDAO.deleteFiles(commentId);

    if (deletedCommentCount != 1) {
        throw new IncorrectUpdateSemanticsDataAccessException("Deleted comment not 1 [deletedCount : " + deletedCommentCount);
    }

    if (deletedFileCount != 1) {
        throw new IncorrectUpdateSemanticsDataAccessException("Deleted file not 1 [deletedCount : " + deletedCommentCount);
    }

}
</code></pre>

<p><code>3. Test Case</code></p>

<pre><code>@Test
public void rollbackT() {
    boolean hasException = false;
    int sizeBeforDelete = commentDAO.selectCountByArticle(1);

    try {
        commentService.deleteCommentAndFiles(1);
    } catch (RuntimeException e) {
        hasException = true;
    }

    Assert.assertTrue(hasException);
    Assert.assertEquals(sizeBeforDelete, commentDAO.selectCountByArticle(1));

}
</code></pre>

<p>in Test case </p>

<p>first <code>Assert.assertTrue(hasException);</code> is passed but</p>

<p><code>Assert.assertEquals(sizeBeforDelete, commentDAO.selectCountByArticle(1))</code> this case fail <code>Expected : 1 but Actual : 0</code></p>

<p>this second TC fail mean Exception is occur but doesn't rollback delete comment</p>

<p><code>deleteCommentAndFiles method</code> throw exception but doesn't rollback</p>

<p>Im trying to use <code>@Transactional(propagation=Propagation.REQUIRED, rollbackFor={IncorrectUpdateSemanticsDataAccessException.class})</code></p>

<p>but same doesn't work</p>

<p>why @Transactional annotaion doesn't work?</p>