Sep 2nd, 2007, 07:41 AM
Will Spring close the connection for me?
I am using a transaction manager and using @Transactional to mark some methods. This is working fine. The connection is closed at the end of the transaction. But what if there is a non-transactional method that creates a connection (using DataSourceUtils.getConnection() or the shared entity manager), will that connection be closed automatically by Spring?
Thanks for any info!
Sep 3rd, 2007, 02:06 AM
Spring will only close the connections for you when you call the template methods defined in the data access templates (such as JdbcTemplate, HibernateTemplate, JpaTemplate). If you create the connections by yourself, they won't be closed by Spring. Whether a database connection will be closed automatically should have no relationship with the transactional configuration.