public void abort ( ) { /* do nothing if already rolledback */ if ( txStatus == Status . STATUS_NO_TRANSACTION || txStatus == Status . STATUS_UNKNOWN || txStatus == Status . STATUS_ROLLEDBACK ) { log . info ( "Nothing to abort, tx is not active - status is " + TxUtil . getStatusString ( txStatus ) ) ; return ; } // check status of tx if ( txStatus != Status . STATUS_ACTIVE && txStatus != Status . STATUS_PREPARED && txStatus != Status . STATUS_MARKED_ROLLBACK ) { throw new IllegalStateException ( "Illegal state for abort call, state was '" + TxUtil . getStatusString ( txStatus ) + "'" ) ; } if ( log . isEnabledFor ( Logger . INFO ) ) { log . info ( "Abort transaction was called on tx " + this ) ; } try { try { doAbort ( ) ; } catch ( Exception e ) { log . error ( "Error while abort transaction, will be skipped" , e ) ; } // used in managed environments, ignored in non-managed this . implementation . getTxManager ( ) . abortExternalTx ( this ) ; try { if ( hasBroker ( ) && getBroker ( ) . isInTransaction ( ) ) { getBroker ( ) . abortTransaction ( ) ; } } catch ( Exception e ) { log . error ( "Error while do abort used broker instance, will be skipped" , e ) ; } } finally { txStatus = Status . STATUS_ROLLEDBACK ; // cleanup things, e.g. release all locks doClose ( ) ; } }
Abort and close the transaction . Calling abort abandons all persistent object modifications and releases the associated locks . Aborting a transaction does not restore the state of modified transient objects