When the jdbc datastore are integrated with a larger application working against a database we have the case in which the external app is in control of the connection pool and the transaction is controlled outside.
The current jdbc-ng code already avoids grabbing a connection and closing it provided the current transaction already has a connection associated to it.
In the case of external control it would be nice to have a method like createJ2eeTransaction(Connection cx) that has the following features:
- builds a transaction with a user provided connection
- never tries to grab another connection for methods that do get the transaction as a param, and from all the methods in FeatureSource/FeatureStore provided the connection is set
- never closes the connection manually (this is already happening provided the transaction is not AUTO_COMMIT)
- never calls directly commit/rollback
The latter can be achieved if we build a special transaction that never actually calls commit/rollback on the connection. Actually, it would be sufficient that the user never manually calls commit/rollback on the transaction, but let's try to be extra sure about it.
From what I see this would be sufficient to perform an integration into a J2EE enviroment where the pool and transaction lifecycles are controlled by a container (provided there is a way to get the current transactions's connection, something that can be done with Spring, not sure with standard J2EE).
Of course it would also be good for any app that has its own (eventually manual) transaction demarcation and connection pool handling