private void onRollBack ( PersistenceDelegator delegator , Map < Object , EventLog > eventCol ) { if ( eventCol != null && ! eventCol . isEmpty ( ) ) { Collection < EventLog > events = eventCol . values ( ) ; Iterator < EventLog > iter = events . iterator ( ) ; while ( iter . hasNext ( ) ) { try { EventLog event = iter . next ( ) ; Node node = event . getNode ( ) ; Class clazz = node . getDataClass ( ) ; EntityMetadata metadata = KunderaMetadataManager . getEntityMetadata ( delegator . getKunderaMetadata ( ) , clazz ) ; Client client = delegator . getClient ( metadata ) ; // do manual rollback, if data is processed, and running // without transaction or with kundera's default transaction // support! if ( node . isProcessed ( ) && ( ! delegator . isTransactionInProgress ( ) || MetadataUtils . defaultTransactionSupported ( metadata . getPersistenceUnit ( ) , delegator . getKunderaMetadata ( ) ) ) ) { if ( node . getOriginalNode ( ) == null ) { Object entityId = node . getEntityId ( ) ; client . remove ( node . getData ( ) , entityId ) ; } else { client . persist ( node . getOriginalNode ( ) ) ; } } // mark it null for garbage collection. event = null ; } catch ( Exception ex ) { log . warn ( "Caught exception during rollback, Caused by:" , ex ) ; // bypass to next event } } } // mark it null for garbage collection. eventCol = null ; }
On roll back .