Hello Johannes,

> I think there's a problem with the FactoryProxy (and also my code
> above) if no transaction exists at all. In that case every method on
> the FactoryProxy will result in obtaining a new connection from the
> underlying DataSource which is never closed. [...]

Yes, this is what I was afraid of. The current implementation relies
on a lot of magic. It is probably hard to get that magic right. As
mentioned below, the only thorough way to do this in jOOQ is to let
jOOQ handle the complete lifecycle of a Connection obtained from a
DataSource.

> This lead me to the following conclusion:
> - If the factories get refactored, they should take care about
> obtaining and closing a connection. This allows for the factories to
> operate in a non-transactional environment too and passing in a
> "TransactionAwareDataSourceProxy" would perfectly integrate them with
> Spring and it's transactional infrastructure.

Yes, Factory will have two operation modes:
1. Taking a Connection, leaving it open at the end of the execution
2. Taking a DataSource, fetching a Connection from it, and closing it
at the end of the execution

> - Therefore there should be no need that any interface or class of
> jOOQ provides a "close" method - I even advise against this.

It would be nice if close() doesn't need to be promoted to the public
API. But I cannot say that yet, as this is a non-trivial refactoring.

> Are there any plans in which version the factories will accept a
> DataSource?

I'll see if this is feasible for jOOQ 2.4.0. I filed ticket #1405 for this:
https://sourceforge.net/apps/trac/jooq/ticket/1405

Being a non-trivial change, I cannot make a guarantee about this, yet.

Cheers
Lukas

Reply via email to