[jboss-dev-forums] [Design of JCA on JBoss] - Re: Allow setAutoCommit(false) on managed connections

adrian@jboss.org do-not-reply at jboss.com
Mon Jul 23 09:24:47 EDT 2007


That would be in violation of the spec. JavaEE5 EE.6.2.4.2
anonymous wrote : 
  | 
  |                                                               The component
  | should not attempt to change the transaction characteristics of the connection,
  | commit the transaction, roll back the transaction, or set autocommit mode.
  | Attempts to make changes that are incompatible with the current transaction
  | context may result in a SQLException being thrown. The EJB speci?cation
  | contains the precise rules for enterprise beans.
  | 

It would also break the semantics of the code:

  | Connection c = dataSource.getConnection();
  | try
  | {
  |    c.setAutoCommit(false);
  |    // do multiple operations
  | }
  | finally
  | {
  |    if (errorOccurred)
  |       c.rollback();
  |    else
  |    {
  |       c.commit();
  |       // HERE WE KNOW THE WORK WAS DONE
  |    }
  | }
  | 

The proposed change would mean we need to ignore the c.commit() as well
(the JTA transaction handles it)
so the assumption in the above code is broken.

I suspect what you really asking for is a piece of configuration
that already exists. i.e. use a no-tx-datasource
such that the code controls the transaction and not the appserver.

Or use NOT_SUPPORTED transaction demarcation (so the 
connection is not enlisted in a JTA transaction - there isn't one).

i.e. You have a misunderstanding about what the real requirements are.

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4066645#4066645

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4066645



More information about the jboss-dev-forums mailing list