public boolean fireRow(Session session,Row oldRow,Row newRow,boolean beforeAction,boolean rollback){
  if (!rowBased || before != beforeAction) {
    return false;
  }
  if (rollback && !onRollback) {
    return false;
  }
  load();
  Object[] oldList;
  Object[] newList;
  boolean fire=false;
  if ((typeMask & Trigger.INSERT) != 0) {
    if (oldRow == null && newRow != null) {
      fire=true;
    }
  }
  if ((typeMask & Trigger.UPDATE) != 0) {
    if (oldRow != null && newRow != null) {
      fire=true;
    }
  }
  if ((typeMask & Trigger.DELETE) != 0) {
    if (oldRow != null && newRow == null) {
      fire=true;
    }
  }
  if (!fire) {
    return false;
  }
  oldList=convertToObjectList(oldRow);
  newList=convertToObjectList(newRow);
  Object[] newListBackup;
  if (before && newList != null) {
    newListBackup=new Object[newList.length];
    System.arraycopy(newList,0,newListBackup,0,newList.length);
  }
 else {
    newListBackup=null;
  }
  Connection c2=session.createConnection(false);
  boolean old=session.getAutoCommit();
  boolean oldDisabled=session.setCommitOrRollbackDisabled(true);
  Value identity=session.getLastScopeIdentity();
  try {
    session.setAutoCommit(false);
    triggerCallback.fire(c2,oldList,newList);
    if (newListBackup != null) {
      for (int i=0; i < newList.length; i++) {
        Object o=newList[i];
        if (o != newListBackup[i]) {
          Value v=DataType.convertToValue(session,o,Value.UNKNOWN);
          newRow.setValue(i,v);
        }
      }
    }
  }
 catch (  Exception e) {
    if (onRollback) {
    }
 else {
      throw DbException.convert(e);
    }
  }
 finally {
    if (session.getLastTriggerIdentity() != null) {
      session.setLastScopeIdentity(session.getLastTriggerIdentity());
      session.setLastTriggerIdentity(null);
    }
 else {
      session.setLastScopeIdentity(identity);
    }
    session.setCommitOrRollbackDisabled(oldDisabled);
    session.setAutoCommit(old);
  }
  return insteadOf;
}

public boolean fireRow ( Session session , Row oldRow , Row newRow , boolean beforeAction , boolean rollback ) { if ( ! rowBased || before != beforeAction ) { return false ; } if ( rollback && ! onRollback ) { return false ; } load ( ) ; Object [ ] oldList ; Object [ ] newList ; boolean fire = false ; if ( ( typeMask & Trigger . INSERT ) != 0 ) { if ( oldRow == null && newRow != null ) { fire = true ; } } if ( ( typeMask & Trigger . UPDATE ) != 0 ) { if ( oldRow != null && newRow != null ) { fire = true ; } } if ( ( typeMask & Trigger . DELETE ) != 0 ) { if ( oldRow != null && newRow == null ) { fire = true ; } } if ( ! fire ) { return false ; } oldList = convertToObjectList ( oldRow ) ; newList = convertToObjectList ( newRow ) ; Object [ ] newListBackup ; if ( before && newList != null ) { newListBackup = new Object [ newList . length ] ; System . arraycopy ( newList , 0 , newListBackup , 0 , newList . length ) ; } else { newListBackup = null ; } Connection c2 = session . createConnection ( false ) ; boolean old = session . getAutoCommit ( ) ; boolean oldDisabled = session . setCommitOrRollbackDisabled ( true ) ; Value identity = session . getLastScopeIdentity ( ) ; try { session . setAutoCommit ( false ) ; triggerCallback . fire ( c2 , oldList , newList ) ; if ( newListBackup != null ) { for ( int i = 0 ; i < newList . length ; i ++ ) { Object o = newList [ i ] ; if ( o != newListBackup [ i ] ) { Value v = DataType . convertToValue ( session , o , Value . UNKNOWN ) ; newRow . setValue ( i , v ) ; } } } } catch ( Exception e ) { if ( onRollback ) { } else { throw DbException . convert ( e ) ; } } finally { if ( session . getLastTriggerIdentity ( ) != null ) { session . setLastScopeIdentity ( session . getLastTriggerIdentity ( ) ) ; session . setLastTriggerIdentity ( null ) ; } else { session . setLastScopeIdentity ( identity ) ; } session . setCommitOrRollbackDisabled ( oldDisabled ) ; session . setAutoCommit ( old ) ; } return insteadOf ; }
call the fire method of the user - defined trigger class if required . this method does nothing if the trigger is not defined for the given action . this method is called before or after a row is processed , possibly many times for each statement .
