> Do I have to create new Factory after connection is closed?

Yes, the life-cycle of a Factory should match the lifecycle of a JDBC
Connection. If you use a container-managed data source, you should
create the Factory when you get the connection, and you should dispose
of the factory, when you close (or surrender) the connection.

> I guess Factory is not thread-safe.

No it isn't. In a container, two threads shouldn't share a JDBC
Connection. This information is missing from the Javadocs. I'll
correct that:
https://sourceforge.net/apps/trac/jooq/ticket/786

> Have you considered Factory constructor with DataSource instead of opened 
> connection?

Yes, but then I would need to handle transactions in jOOQ. I think
transaction handling (as well as session handling, second-level
caching, etc) should be handled in client code, using EJB 2.0, EJB
3.x, Spring, JBoss Cache, EhCache or any other tools.

I'm not sure I would be able to find a simple solution that fits all.
I'm open to ideas, though.

Please note, that there are some related topics handled in the
serialisation of jOOQ objects. Maybe this can be of help, too:
https://sourceforge.net/apps/trac/jooq/wiki/Manual/JOOQ/Serializability

Reply via email to