<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=mattinger" rel="nofollow">matthew inger</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-834?redirect=false" rel="nofollow">SPR-834</a></strong> and commented</p>
<p dir="auto">The LocalSessionFactory bean currently has no way to set listeners on the SessionFactory (via the Configuration.setListener) method.  This should as simple as accepting a map as a property of the LocalSessionFactoryBean, and when building the Configuration object, iterating through it, and calling Configuration.setListener on each iteration.</p>
<hr>
<p dir="auto"><strong>Affects:</strong> 1.2 RC1</p>
<p dir="auto"><strong>Attachments:</strong></p>
<ul dir="auto">
<li><a href="https://jira.spring.io/secure/attachment/10623/LocalSessionFactoryBean.patch" rel="nofollow">LocalSessionFactoryBean.patch</a> (<em>2.93 kB</em>)</li>
</ul>
<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="398055681" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/5519" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/5519/hovercard" href="https://github.com/spring-projects/spring-framework/issues/5519">#5519</a> Support For Event Listeners (<em><strong>"is duplicated by"</strong></em>)</li>
</ul>
<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=cbeams" rel="nofollow">Chris Beams</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-8114?redirect=false" rel="nofollow">SPR-8114</a></strong> and commented</p>
<p dir="auto">When using Spring's <code class="notranslate">FactoryBean</code> types such as <code class="notranslate">LocalSessionFactoryBean</code> destruction of the actual bean (the Hibernate <code class="notranslate">Session</code> in the case of <code class="notranslate">LSFB</code>) is usually handled automatically by the <code class="notranslate">FactoryBean</code>.</p>
<p dir="auto">However, when using Spring's new <code class="notranslate">*Builder</code> APIs within <code class="notranslate">@Bean</code> methods, no <code class="notranslate">FactoryBean</code>-like object is registered with the container.  This means that it is up to the user to <em>remember</em> to configure the <code class="notranslate">destroy-method</code> attribute of the <code class="notranslate">@Bean</code> annotation, which is likely to be forgotten.</p>
<p dir="auto">To remedy this situation, Spring should automatically detect common close/destruction method names and signatures and automatically invoke them at container shutdown time.</p>
<p dir="auto">Obviously, Spring's <code class="notranslate">DisposableBean</code> is already supported in this way, as are methods annotated with <code class="notranslate">@PreDestroy</code>.  When dealing with third-party types, however, the user is not at liberty to add these interfaces/annotations.  In the case of Hibernate's <code class="notranslate">Session</code> interface, the method to be called is</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="public Connection close() throws HibernateException;"><pre class="notranslate"><code class="notranslate">public Connection close() throws HibernateException;
</code></pre></div>
<p dir="auto">As this method is not annotated in any way nor does it implement any standard interface with destruction semantics, we can only assume based on it's name that it is to be invoked.</p>
<hr>
<p dir="auto"><strong>Attachments:</strong></p>
<ul dir="auto">
<li><a href="https://jira.spring.io/secure/attachment/18077/mylyn-context.zip" rel="nofollow">mylyn-context.zip</a> (<em>4.40 kB</em>)</li>
<li><a href="https://jira.spring.io/secure/attachment/18076/mylyn-context.zip" rel="nofollow">mylyn-context.zip</a> (<em>4.40 kB</em>)</li>
</ul>
<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="398106515" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/12076" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/12076/hovercard" href="https://github.com/spring-projects/spring-framework/issues/12076">#12076</a> Provide alternatives to using FactoryBean types within <code class="notranslate">@Bean</code> methods</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/5c27a042101b3ab5eaba12c440b194c88f53e685/hovercard" href="https://github.com/spring-projects/spring-framework/commit/5c27a042101b3ab5eaba12c440b194c88f53e685"><tt>5c27a04</tt></a>, <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/spring-projects/spring-framework/commit/1a8531b4013c945f72b7666b4de305529b68d481/hovercard" href="https://github.com/spring-projects/spring-framework/commit/1a8531b4013c945f72b7666b4de305529b68d481"><tt>1a8531b</tt></a></p>