<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=urferr" rel="nofollow">Reto Urfer</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-9020?redirect=false" rel="nofollow">SPR-9020</a></strong> and commented</p>
<p dir="auto">The Hibernate4 support of Spring 3.1 does not open and register a session in case of the method called is annotated with <code class="notranslate">@Transactional</code>(propagation = Propagation.SUPPORTS).<br>
In this case HibernateTransactionManager.doBegin() is never called which is the only place where hibernate session is opened. The result is, that all read operations which do not require a transaction will fail because the call to SessionFactory.currentSession() will result in an exception.</p>
<p dir="auto">The Hibernate3 implementation contains a fallback for this case in SessionFactoryUtils.doGetSession(...) which is missing in the corresponding Hibernate4 implementation of SpringSessionContext.currentSession().</p>
<p dir="auto">If the transaction propagation is changed to REQUIRES_NEW everything is working fine.</p>
<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="398168395" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/16421" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/16421/hovercard" href="https://github.com/spring-projects/spring-framework/issues/16421">#16421</a> Hibernate4 version of SpringSessionContext.currentSession() does not create a session if TransactionSynchronizationManager does not contain one (<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="398115956" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/13548" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/13548/hovercard" href="https://github.com/spring-projects/spring-framework/issues/13548">#13548</a> org.springframework.orm.hibernate4.HibernateTransactionManager fails with NoSuchMethodError against SessionFactory.getCurrentSession()</li>
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398180240" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/17680" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/17680/hovercard" href="https://github.com/spring-projects/spring-framework/issues/17680">#17680</a> H4 SpringSessionSynchronization#beforeCompletion leaves irreparably broken state if exception thrown in session.disconnect()</li>
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398173138" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/16954" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/16954/hovercard" href="https://github.com/spring-projects/spring-framework/issues/16954">#16954</a> HibernateTransactionManager should allow holdability of ResultSet into the View layer</li>
</ul>
<p dir="auto">19 votes, 28 watchers</p>
<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=lfty" rel="nofollow">Jan Dudek</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-9030?redirect=false" rel="nofollow">SPR-9030</a></strong> and commented</p>
<p dir="auto">Let's have this following class:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="@Component
public class TestClass {
    private List&lt;RelatedClass2&gt; propertyRelatedClasses;


    public List&lt;RelatedClass2&gt; getPropertyRelatedClasses() {
        return propertyRelatedClasses;
    }


    @Inject
    public void setPropertyRelatedClasses(Provider&lt;List&lt;RelatedClass2&gt;&gt; propertyRelatedClassesProvider) {
        this.propertyRelatedClasses = propertyRelatedClassesProvider.get();
    }
}

I want to inject a `List` of all existing instances of type `RelatedClass2` using a Provider. What I get is:
"><pre class="notranslate"><code class="notranslate">@Component
public class TestClass {
    private List&lt;RelatedClass2&gt; propertyRelatedClasses;


    public List&lt;RelatedClass2&gt; getPropertyRelatedClasses() {
        return propertyRelatedClasses;
    }


    @Inject
    public void setPropertyRelatedClasses(Provider&lt;List&lt;RelatedClass2&gt;&gt; propertyRelatedClassesProvider) {
        this.propertyRelatedClasses = propertyRelatedClassesProvider.get();
    }
}

I want to inject a `List` of all existing instances of type `RelatedClass2` using a Provider. What I get is:

</code></pre></div>
<p dir="auto">...<br>
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [java.lang.Object] is defined: expected single matching bean but found 15: [relatedClass1, 2b, 2a, org.springframework.context.annotation.internalConfigurationAnnotationProcessor, org.springframework.context.annotation.internalAutowiredAnnotationProcessor, org.springframework.context.annotation.internalRequiredAnnotationProcessor, org.springframework.context.annotation.internalCommonAnnotationProcessor, org.springframework.context.annotation.internalPersistenceAnnotationProcessor, org.springframework.context.annotation.ConfigurationClassPostProcessor$ImportAwareBeanPostProcessor#0, environment, systemProperties, systemEnvironment, importRegistry, messageSource, applicationEventMulticaster]<br>
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:800)<br>
at org.springframework.beans.factory.support.DefaultListableBeanFactory$DependencyObjectFactory.getObject(DefaultListableBeanFactory.java:1023)<br>
at org.springframework.beans.factory.support.DefaultListableBeanFactory$DependencyProvider.get(DefaultListableBeanFactory.java:1038)<br>
at com.gooddata.connectors.restapi.controller.springtest.TestClass.setPropertyRelatedClasses(TestClass.java:25)<br>
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="
The ```
2a
``` and 
```2b
``` beans are of type `RelatedClass2`."><pre class="notranslate"><code class="notranslate">
The ```
2a
``` and 
```2b
``` beans are of type `RelatedClass2`.
</code></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="398117073" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/13730" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/13730/hovercard" href="https://github.com/spring-projects/spring-framework/issues/13730">#13730</a> Injecting / autowiring collection provider doen't work (<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/c55362c35e0c098d3e7fb9c5c749e180382bbca8/hovercard" href="https://github.com/spring-projects/spring-framework/commit/c55362c35e0c098d3e7fb9c5c749e180382bbca8"><tt>c55362c</tt></a></p>