--
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 jooq-user+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to a topic in the Google Groups "jOOQ User Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jooq-user/xkK48Mrh5so/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jooq-user+...@googlegroups.com.
Hi,
I think it could be much easier to ask for @Resource DataSource, and use just that for jOOQ...
You can create a producer which provides DSLContext, so in any bean you can just @Inject it instead of EntityManager, or you can have both injected if needed (EM using @PersistenceContext of course).
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?
public class DataSourceConnectionProvider implements ConnectionProvider {private final DataSource dataSource;public DataSourceConnectionProvider(DataSource dataSource) {this.dataSource = dataSource;}public DataSource dataSource() {return dataSource;}@Overridepublic Connection acquire() {try {return dataSource.getConnection();}catch (SQLException e) {throw new DataAccessException("Error getting connection from data source " + dataSource, e);}}@Overridepublic void release(Connection connection) {try {connection.close();}catch (SQLException e) {throw new DataAccessException("Error closing connection " + connection, e);}}}
--