brettwooldridge / SansOrm

A "No-ORM" sane SQL ←→ Java object mapping library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Question concering closing connections in SqlClosure

hdconradi opened this issue · comments

This is probably just a stupid question, but here we go:

At the end of the public final T execute() method of SqlClosure the finally clause within the finally (line 227) applies for all connections, regardless of the value of txOwner.
I.e. a connection is closed, even when an external TransactionManager is present.
Is that intendet?

As I see it, the connection comes from

dataSource.getConnection() (line 194)

Usually a DataSource provides connections from a connection pool. Calling close() on a connection obtained from a pool is mandatory to give the connection back to the pool so it is freed for reusage. The connection is not really closed.

@hdconradi @h-thurow That is correct.

My company used to use the Bitronix JTA Transaction Manager, and so I know that SansOrm works with that JTM. We now use the internal Transaction Manager, because we never had multiple, distirbuted, databases, but wanted the Connection sharing/thread-association behavior.