<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=ndeloof" rel="nofollow">nicolas de loof</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-2605?redirect=false" rel="nofollow">SPR-2605</a></strong> and commented</p>
<p dir="auto">Containers like plexus use field injection. According to <a href="http://forum.springframework.org/showthread.php?t=9692&amp;highlight=field+injection" rel="nofollow">http://forum.springframework.org/showthread.php?t=9692&amp;highlight=field+injection</a>, This is not considered by Spring developers as a good practice.</p>
<p dir="auto">I myself had a case where it may be better than setter injection :</p>
<p dir="auto">A newbee developper coded into a Struts action injection of values into it's dependencies using public setters. Dependency may use a facade interface but was not in this case (generated code). This is not Spring responsibility to avoid such errors, but requirement for public setters exposes components internals.</p>
<p dir="auto">Having protected (or package) field for dependencies keeps code testability (only require the testcase to be in the same package) and avoid exposing unnecessary setters.</p>
<p dir="auto">Field injection requires Spring to make some "magic" Privileged actions, but Hibernate and JPA also do AFAIK.</p>
<p dir="auto">Could you please reconsider this and expose a definitive argument to exclude field injection from Spring scope ?</p>
<hr>
<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="398093823" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/10249" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/10249/hovercard" href="https://github.com/spring-projects/spring-framework/issues/10249">#10249</a> <code class="notranslate">@Autowired</code> vs. &lt;property (<em><strong>"is duplicated by"</strong></em>)</li>
</ul>
<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=skaffman" rel="nofollow">Kenny MacLeod</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-3759?redirect=false" rel="nofollow">SPR-3759</a></strong> and commented</p>
<p dir="auto">This is a non-backward-compatible change, but I think JdbcDaoSupport should expose its JdbcTemplate object as a JdbcOperations type.  The current implementation is hard to test, since you cannot inject a mock JdbcOperations object into the DAO, you can only inject a JdbcTemplate.  This is less test friendly.</p>
<p dir="auto">I appreciate this is a tricky one to manage, however.  Perhaps some balance of JdbcOperations injection and getJdbcTemplate() could be achieved?</p>
<hr>
<p dir="auto"><strong>Affects:</strong> 2.0.6</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="398082620" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/8782" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/8782/hovercard" href="https://github.com/spring-projects/spring-framework/issues/8782">#8782</a> JdbcDaoSupport.setJdbcTemplate() should accept JdbcOperations (<em><strong>"is duplicated by"</strong></em>)</li>
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398083018" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/8832" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/8832/hovercard" href="https://github.com/spring-projects/spring-framework/issues/8832">#8832</a> HibernateDaoSupport should use HibernateOperations in method signatures</li>
</ul>
<p dir="auto">2 votes, 1 watchers</p>