<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=matsev" rel="nofollow">Mattias Severson</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-9032?redirect=false" rel="nofollow">SPR-9032</a></strong> and commented</p>
<p dir="auto">Step by step:</p>
<ol dir="auto">
<li>Go to <a href="http://docs.spring.io/spring/docs/current/spring-framework-reference/htmlsingle/#testcontext-tx" rel="nofollow">http://docs.spring.io/spring/docs/current/spring-framework-reference/htmlsingle/#testcontext-tx</a></li>
<li>Scroll down to "Avoid false positives when testing ORM code"</li>
<li>Find how to include SessionFactory and flush() is used to avoid false positives if you are using Hibernate.</li>
</ol>
<p dir="auto">The information is good, but it is not applicable if you use JPA. To avoid false positives when using JPA (backed by Hibernate) I propose that you add a new snippet that the describes a different approach. Suggested implementation:</p>
<div class="highlight highlight-source-java notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="@PersistenceContext
EntityManager entityManager;

@Test(expected = GenericJDBCException.class)
public void updateWithSessionFlush() {
    updateJpaEntity();
    // Manual flush is required to avoid false positive in test
    entityManager.unwrap(Session.class).flush();
}"><pre class="notranslate"><span class="pl-c1">@</span><span class="pl-c1">PersistenceContext</span>
<span class="pl-smi">EntityManager</span> <span class="pl-s1">entityManager</span>;

<span class="pl-c1">@</span><span class="pl-c1">Test</span>(<span class="pl-s1">expected</span> = <span class="pl-smi">GenericJDBCException</span>.<span class="pl-k">class</span>)
<span class="pl-k">public</span> <span class="pl-smi">void</span> <span class="pl-s1">updateWithSessionFlush</span>() {
    <span class="pl-en">updateJpaEntity</span>();
    <span class="pl-c">// Manual flush is required to avoid false positive in test</span>
    <span class="pl-s1">entityManager</span>.<span class="pl-en">unwrap</span>(<span class="pl-smi">Session</span>.<span class="pl-k">class</span>).<span class="pl-en">flush</span>();
}</pre></div>
<hr>
<p dir="auto"><strong>Affects:</strong> 3.1 GA</p>
<p dir="auto"><strong>Issue Links:</strong></p>
<ul dir="auto">
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398187054" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/18296" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/18296/hovercard" href="https://github.com/spring-projects/spring-framework/issues/18296">#18296</a> Doc: Flush in test with SessionFactory vs EntityManager (<em><strong>"is duplicated by"</strong></em>)</li>
</ul>
<p dir="auto"><strong>Referenced from:</strong> commits <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/spring-projects/spring-framework/commit/64c388d5242076ac7a95af1bd03ea276157596af/hovercard" href="https://github.com/spring-projects/spring-framework/commit/64c388d5242076ac7a95af1bd03ea276157596af"><tt>64c388d</tt></a></p>
<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=yozh" rel="nofollow">Stepan Koltsov</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-4104?redirect=false" rel="nofollow">SPR-4104</a></strong> and commented</p>
<p dir="auto">JdbcDaoSupport.setJdbcTemplate() accepts JdbcTemplate as argument. It would be better if argument was JdbcOperations.</p>
<p dir="auto">Rationale: I have reflective proxy of JdbcTemplate that measures query execution times. Such proxy does not extend JdbcTemplate, but rather implement JdbcOperations. So I cannot inject this proxy into JdbcDaoSupport.</p>
<hr>
<p dir="auto"><strong>Affects:</strong> 2.5 RC1</p>
<p dir="auto"><strong>Issue Links:</strong></p>
<ul dir="auto">
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398079985" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/8440" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/8440/hovercard" href="https://github.com/spring-projects/spring-framework/issues/8440">#8440</a> Alter JdbcDaoSupport to use JdbcOperations instead of JdbcTemplate (<em><strong>"duplicates"</strong></em>)</li>
</ul>