<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=bonhamcm" rel="nofollow">Chris Bonham</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-7833?redirect=false" rel="nofollow">SPR-7833</a></strong> and commented</p>
<p dir="auto">Sometimes it is necessary to strictly update the cache without retrieving the value first, for example when pre-loading a cache.  I've created a patch that adds a boolean updateOnly flag to the <code class="notranslate">@Cacheable</code> annotation that is false by default.  If set to true, the underlying cache is not consulted, but rather the return value is placed directly in the cache.</p>
<hr>
<p dir="auto"><strong>Affects:</strong> 3.1 M1</p>
<p dir="auto"><strong>Attachments:</strong></p>
<ul dir="auto">
<li><a href="https://jira.spring.io/secure/attachment/17472/updateOnly.patch" rel="nofollow">updateOnly.patch</a> (<em>4.83 kB</em>)</li>
</ul>
<p dir="auto">3 votes, 2 watchers</p>
<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=medined" rel="nofollow">David Medinets</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-1956?redirect=false" rel="nofollow">SPR-1956</a></strong> and commented</p>
<p dir="auto">Given a bean definition like this:</p>
<p dir="auto">&lt;bean id="com.foo.BarRepository" class="com.foo.BarRepositoryJDO"&gt;<br>
&lt;constructor-arg&gt;&lt;ref bean="javax.jdo.PersistenceManagerFactory" /&gt;&lt;/constructor-arg&gt;<br>
&lt;/bean&gt;</p>
<p dir="auto">If the beanFactory.getBean(Bar.class) signature were supported (ie, added to the BeanFactory interface), it would be possible to do:</p>
<p dir="auto">BarRepository barRepository = (BarRepository)beanFactory.getBean(BarRepository.class);</p>
<p dir="auto">This syntax is better than getBean("barRepository") because the Java compiler verifies the class name is spelled correctly. While advanced IDEs (ie, Eclipse) support does handle class name verification, not all people will be using such an IDE.</p>
<p dir="auto">It may or may not be a good idea to require the Class to actually be an interface to ensure that 'best practices' are followed.</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="398093503" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/10200" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/10200/hovercard" href="https://github.com/spring-projects/spring-framework/issues/10200">#10200</a> Support BeanFactory#getBean(Class requiredType) (<em><strong>"duplicates"</strong></em>)</li>
</ul>
<p dir="auto">1 votes, 1 watchers</p>