views:

124

answers:

1

We have some third party code wherein they do the following

1) Create a User Transaction e.g.

     txn = (UserTransaction)ctx.lookup( "UserTransaction" );
     txn.begin(  );

2) Do some work persisting to the database (via JPA) to a MySQL database

3) txn.commit()

They have Exception blocks but NONE of them call txn.rollback. Good coding practice says they NEED to call rollback if an exception occurs but my question is If the txn is not commited, and an exception occurs what is the negative effect of them NOT calling rollback?

+2  A: 

The transaction stays active, until you either commit() or rollback() it. It will continue to hold locks and you may end up blocking your application (database, actually).

Bozho