Garret,

Just checking, have you already used a debugger to step through all the
jOOQ / ULTM code, etc?

2014-12-10 16:04 GMT+01:00 Garret Wilson <[email protected]>:

>  On 12/9/2014 7:52 AM, Witold Szczerba wrote:
>
> ...
>
> So now that this SQL statement is finished and executed, jOOQ will "close"
> the connection, which normally would return it to the pool. Does TxManager
> step in and keep the connection from going back into the pool?
>
>  Yes, it does. Connection does not go back to pool yet.
>
>
>  9. So now let's start storing the car:
>
>        CarRecord carRecord = dslTransaction.newRecord(CAR);
>        ...
>        carRecord.store();
>
> Again, where does jOOQ get its connection? Does the managed data source
> ensure that it gets the same connection as before? After the transaction is
> over, does the manage data source simply pass the connection requests (that
> are not part of any transaction) on to the underlying data source? If this
> is how it all works, then I suppose it's starting to make sense.
>
>  As I said in previous posts, jOOQ will get the same connection each
> time within TxManager transaction. It won't close, commit, rollback or
> give it back to the pool until TxManager say so.
>
>
>
> OK, Witold, that makes sense and I like it. But just to clear up in my
> mind how this all works, I wonder about the default jOOQ behavior if I
> simply have a jOOQ Configuration wrapping a data source (with no Spring and
> no pooling and no anything else).
>
> Lukas, if I do *not* use ULTM, and if I manually turn off autocommit on a
> connection and then issue several jOOQ SQL commands, will jOOQ (via the
> DataSourceConnectionProvider) request a different connection for each
> command?
>

Where would you turn off autocommit manually, if you use a DataSource? Did
you implement your own DataSource?


> (I read that jOOQ will close the connection after execution of each
> command.)
>

Yes. Here:
https://github.com/jOOQ/jOOQ/blob/c6730094b662b228b121a88013e8251a78c28cb6/jOOQ/src/main/java/org/jooq/impl/DataSourceConnectionProvider.java#L96


> If so, then it would seem that all of the jOOQ commands are using separate
> connections, because in this scenario I have no connection pool and I don't
> have ULTM installed.
>

jOOQ wouldn't know because jOOQ's DataSourceConnectionProvider just takes
whatever Connection comes out of the DataSource:
https://github.com/jOOQ/jOOQ/blob/c6730094b662b228b121a88013e8251a78c28cb6/jOOQ/src/main/java/org/jooq/impl/DataSourceConnectionProvider.java#L86


> To simplify my question: with a DSLContext created from a jOOQ
> configuration backed by a data source, if I manage transactions manually on
> a connection,
>
what is stopping jOOQ from creating new connections for each command using
> the default DataSourceConnectionProvider?
>

jOOQ will always ask YOU for a Connection, either because you supply a
standalone Connection, or because your DataSource supplies one.


> (I am beginning to think that the answer is, "this won't work, because
> jOOQ will indeed request a new connection for each command.
>

No. jOOQ will request ANY Connection for each command. jOOQ doesn't care
how YOU produce that Connection. That's your business.


> I suspect it only works in our application because the developer is
> passing around a JDBC connection instance during a transaction, and forming
> a DSLContext via DSL.using(connection) from the transaction connection
> rather than DSL.using(jooqConfiguration).)
>

That will always work, yes.

-- 
You received this message because you are subscribed to the Google Groups "jOOQ 
User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to