2014-10-10 17:52 GMT+02:00 John Edo <[email protected]>:

> Thanks all. I’ll give that approach a try.
>
> One concern: is the connection returned by the datasource part of the
> active JTA transaction? e.g. suppose the jOOQ SQL runs fine, but
> subsequently something else causes the JTA transaction to rollback…will the
> jOOQ SQL be rolled back too?
>

Yes - by default, jOOQ is completely unaware of your transaction
implementation and just uses org.jooq.ConnectionProviders to acquire JDBC
Connections from which it then creates PreparedStatements without any
magic. After statement execution, the Connection is released again to the
ConnectionProvider

If you provide jOOQ with a DataSource, you are implicitly using a
DataSourceConnectionProvider, and the following logic is used to acquire /
release connections:

public class DataSourceConnectionProvider implements ConnectionProvider {

    private final DataSource dataSource;

    public DataSourceConnectionProvider(DataSource dataSource) {
        this.dataSource = dataSource;
    }

    public DataSource dataSource() {
        return dataSource;
    }

    @Override
    public Connection acquire() {
        try {
            return dataSource.getConnection();
        }
        catch (SQLException e) {
            throw new DataAccessException("Error getting connection from
data source " + dataSource, e);
        }
    }

    @Override
    public void release(Connection connection) {
        try {
            connection.close();
        }
        catch (SQLException e) {
            throw new DataAccessException("Error closing connection " +
connection, e);
        }
    }
}


More details can be seen here:
http://www.jooq.org/doc/latest/manual/sql-building/dsl-context/connection-vs-datasource/

Hope this helps,
Lukas

-- 
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