The magic happens when you use transactionAwareDataSource together with
transaction interceptor. It cares about closing.
For example:
<tx:annotation-driven transaction-manager="transactionManager"/>
<jdbc:embedded-database id="dataSource" type="HSQL">
<jdbc:script location="classpath:db-init.sql"/>
</jdbc:embedded-database>
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"/>
</bean>
<bean id="transactionAwareDataSource"
class="org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy">
<constructor-arg ref="dataSource"/>
</bean>
On Thu, Apr 26, 2012 at 10:20 PM, ericjs <[email protected]> wrote:
> Thanks, Sergey! I see, pretty much a pure proxy, allowing the
> datasource to be injected in just a single place. Nice!
>
> I think I see a problem though. I don't see anything ever closing the
> connections being created. Am I missing something?