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.

Reply via email to