<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=eberhardwolff" rel="nofollow">Eberhard Wolff</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-7170?redirect=false" rel="nofollow">SPR-7170</a></strong> and commented</p>
<p dir="auto">In JavaConfig beans created by protected methods with <code class="notranslate">@Bean</code> annotation had visibility inside the <code class="notranslate">@Configuration</code> class only but were not exported into the global <code class="notranslate">ApplicationContext</code> and therefore cannot be referenced from there or other <code class="notranslate">@Configuration</code> annotated classes:</p>
<div class="highlight highlight-source-java notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="@Configuration
public class MyConfiguration {
  @Bean
  public ABean globallyVisible() { ... }

  @Bean
  protected ABean visibleOnlyInThisClass() { ... }
}"><pre class="notranslate"><span class="pl-c1">@</span><span class="pl-c1">Configuration</span>
<span class="pl-k">public</span> <span class="pl-k">class</span> <span class="pl-smi">MyConfiguration</span> {
  <span class="pl-c1">@</span><span class="pl-c1">Bean</span>
  <span class="pl-k">public</span> <span class="pl-smi">ABean</span> <span class="pl-en">globallyVisible</span>() { ... }

  <span class="pl-c1">@</span><span class="pl-c1">Bean</span>
  <span class="pl-k">protected</span> <span class="pl-smi">ABean</span> <span class="pl-en">visibleOnlyInThisClass</span>() { ... }
}</pre></div>
<p dir="auto">This is great to structure large configuration because beans can be hidden. Bring that feature back please.</p>
<hr>
<p dir="auto"><strong>Affects:</strong> 3.0 GA, 3.0.1, 3.0.2</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="398111454" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/12839" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/12839/hovercard" href="https://github.com/spring-projects/spring-framework/issues/12839">#12839</a> Revised support for bean definition visibility and overriding (<em><strong>"is depended on by"</strong></em>)</li>
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398073079" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/7548" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/7548/hovercard" href="https://github.com/spring-projects/spring-framework/issues/7548">#7548</a> Allow to restrict the visibility of beans to a file (<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="398094306" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/10325" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/10325/hovercard" href="https://github.com/spring-projects/spring-framework/issues/10325">#10325</a> Consider using javassist for proxy generation</li>
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398110303" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/12637" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/12637/hovercard" href="https://github.com/spring-projects/spring-framework/issues/12637">#12637</a> Support profile exclusivity and/or bean definition finality</li>
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398082106" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/8713" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/8713/hovercard" href="https://github.com/spring-projects/spring-framework/issues/8713">#8713</a> Exporting / Importing beans across ApplicationContexts</li>
</ul>
<p dir="auto">27 votes, 22 watchers</p>
<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=martinahrer" rel="nofollow">Martin Ahrer</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-5235?redirect=false" rel="nofollow">SPR-5235</a></strong> and commented</p>
<p dir="auto">org.springframework.orm.jpa.vendor.HibernateJpaDialect.getSession should not try to cast directly to HibernateEntityManager since there is a chance that the entity manager passed in is just a proxy for the EntityManager interface!</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="protected Session getSession(EntityManager em) {
	return ((HibernateEntityManager) em).getSession();
}"><pre class="notranslate"><code class="notranslate">protected Session getSession(EntityManager em) {
	return ((HibernateEntityManager) em).getSession();
}
</code></pre></div>
<p dir="auto">This cast can be avoided (see below)</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="protected Session getSession(EntityManager em) {
	return (Session) em.getDelegate();
}"><pre class="notranslate"><code class="notranslate">protected Session getSession(EntityManager em) {
	return (Session) em.getDelegate();
}
</code></pre></div>
<p dir="auto">I'm facing this problem while I'm trying to integrate Seam with Spring. Seam is in charge of managing the life time of the entity manager and passing it on to Spring using org.jboss.seam.ioc.spring.SeamManagedEntityManagerFactoryBean.</p>
<p dir="auto">Currently a work around is to subclass HibernateJpaDialect and implement getSession as shown!</p>
<hr>
<p dir="auto"><strong>Affects:</strong> 2.5.5</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="398091508" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/9910" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/9910/hovercard" href="https://github.com/spring-projects/spring-framework/issues/9910">#9910</a> HibernateJpaDialect.getSession casting to HibernateEntityManager (<em><strong>"is duplicated by"</strong></em>)</li>
</ul>