Some more feedback on this thread, after more "offline" discussions with stargate. Here are a couple of rules I'd like to establish for this kind community support, to help prevent it from getting as confusing as this thread:
1. This user group is the official jOOQ Community Channel. Blog posts as the one linked from this thread ( http://blog.uws.ie/2013/04/using-jooq-with-spring-transactions/) are inofficial experiments by third party users and will generally NOT be supported. As these posts have it, they're snapshots of what those people are experiencing at a given moment in time. In that case, April 2013. They are very unlikely to update their blog as well as we update our manual, so please do not rely on such outdated blog posts too often. 2. Please, if possible, do not send offline messages to community participants when discussing an issue. If it didn't happen on the user group, it didn't happen at all. 3. Right now we will officially support the jOOQ / Spring integration as set out in the manual: http://www.jooq.org/doc/3.2/manual/getting-started/tutorials/jooq-with-spring/. If you feel that a given integration is not well supported, please help us support it *officially*, by contributing self-contained, working, Maven-built integration test cases, which we can then integrate in continuous integration and documentation. This is the best way to guarantee that future visitors will not be mislead by outdated blog posts. There are hundreds of ways you can set up a project with all possible Open Source DI, JDBC, TX frameworks, which leads to great complexity. Let us strive together to have the official documentation cover as many use-cases as possible in order for future visitors not to end up on any outdated, inofficial blog posts via Google. TL;DR: Maven-based integration test case contributions are very welcome! Cheers Lukas 2014/1/16 Lukas Eder <[email protected]> > For other readers of this thread: > > "stargate" and I have discussed "offline". We're looking forward to a > self-contained little Maven project to reproduce the latest issue. The > thread has started to become a bit difficult to follow, with all the code > snippets and dependencies involved. > > Cheers > Lukas > > > 2014/1/13 Stargate <[email protected]> > >> Hi, >> >> ok the Transactions are working now.. but if i did not add the >> @Transcational Annotation to a Class or method the AutoCommit did not work.. >> >> the Problem is in the "SpringExceptionTranslationExecuteListener" that i >> use: >> >> >> public class SpringExceptionTranslationExecuteListener extends >>> DefaultExecuteListener { >>> >>> >>> @Override >>> public void start(ExecuteContext ctx) { >>> DataSource dataSource=null; >>> try { >>> dataSource= dataSourceSingleton.getDataSource(); >>> } catch (Exception e) { >>> e.printStackTrace(); >>> } >>> >>> Connection con=DataSourceUtils.getConnection(dataSource); >>> >>> DefaultConnectionProvider dCP=new DefaultConnectionProvider(con); >>> >>> ctx.connectionProvider(dCP); >>> >>> >>> } >>> >>> @Override >>> public void exception(ExecuteContext ctx) { >>> >>> DataSourceSingleton dataSourceSingleton = >>> DataSourceSingleton.getReference(); >>> DataSource dataSource=null; >>> try { >>> dataSource= dataSourceSingleton.getDataSource(); >>> } catch (Exception e) { >>> e.printStackTrace(); >>> } >>> >>> >>> SQLException ex = ctx.sqlException(); >>> Statement stmt = ctx.statement(); >>> Connection con = ctx.connection(); >>> >>> DataSourceUtils.releaseConnection(con, dataSource3); >>> >>> JdbcUtils.closeStatement(stmt); >>> >>> >>> ctx.exception(getExceptionTranslator(dataSource3).translate("jOOQ",ctx.sql(), >>> ex)); >>> >>> >>> } >>> >>> /** >>> * Return the exception translator for this instance. >>> * <p> >>> * Creates a default {@link SQLErrorCodeSQLExceptionTranslator} for >>> the >>> * specified DataSource if none set, or a >>> * {@link SQLStateSQLExceptionTranslator} in case of no DataSource. >>> */ >>> public synchronized SQLExceptionTranslator getExceptionTranslator( >>> DataSource dataSource) { >>> final SQLExceptionTranslator exceptionTranslator; >>> if (dataSource != null) { >>> exceptionTranslator = new SQLErrorCodeSQLExceptionTranslator( >>> dataSource); >>> } else { >>> exceptionTranslator = new SQLStateSQLExceptionTranslator(); >>> } >>> return exceptionTranslator; >>> } >>> >>> >>> >>> } >>> >> >> >> and the Problem is this part: >> >> >> @Override >>> public void start(ExecuteContext ctx) { >>> DataSource dataSource=null; >>> try { >>> dataSource= dataSourceSingleton.getDataSource(); >>> } catch (Exception e) { >>> e.printStackTrace(); >>> } >>> >>> Connection con=DataSourceUtils.getConnection(dataSource); >>> >>> DefaultConnectionProvider dCP=new DefaultConnectionProvider(con); >>> >>> ctx.connectionProvider(dCP); >>> >>> } >>> >> >> >> if i uncomment the following line "ctx.connectionProvider(dCP);" the >> AutoCommit will work, but then the Transactions are not working. I have a >> pooled connection and so i must set the connection directly if i want use >> the @Transactional Annotation.. >> >> But if there is no @Transactional Annotation and i set the connection >> directly "ctx.connectionProvider(dCP);" the AutoCommit is not working.. >> How can i fix this problem ? Im new in AOP,Interceptors and so on >> >> The binding for Guice looks like this >> >> bindInterceptor(Matchers.annotatedWith(Transactional.class), >> >> Matchers.not(Matchers.annotatedWith(NotTransactional.class)), >> transactionalMethodInterceptor); >> >> bindInterceptor(Matchers.any(), >> Matchers.annotatedWith(Transactional.class), >> transactionalMethodInterceptor); >> >> >> and the transactionMethodInterceptor is responsible for the spring >> managed Transactionhandling. >> >> >> class TransactionalMethodInterceptor implements MethodInterceptor { >>> >>> @Inject >>> private DataSourceTransactionManager transactionManager; >>> >>> @Override >>> public Object invoke(final MethodInvocation invocation) throws >>> Throwable { >>> DefaultTransactionDefinition transactionDefinition = new >>> DefaultTransactionDefinition(); >>> TransactionStatus transaction = >>> transactionManager.getTransaction(transactionDefinition); >>> try { >>> Object result = invocation.proceed(); >>> try { >>> transactionManager.commit(transaction); >>> } catch (UnexpectedRollbackException e) { >>> LoggerFactory.getLogger(getClass()).error( >>> "commit failed - ignoring! : " + e.getMessage()); >>> } >>> return result; >>> } catch (Exception e) { >>> >>> transactionManager.rollback(transaction); >>> >>> throw e; >>> } >>> } >>> >>> } >>> >> >> >> Best regards >> >> -- >> 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/groups/opt_out. >> > > -- 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/groups/opt_out.
