src/main/java/org/beigesoft/replicator/service/SrvClearDatabase.java
@Override
  public final void make(
    final Map<String, Object> pAddParams) throws Exception {
    ArrayList<Class<?>> classesArr =
      new ArrayList<Class<?>>(this.mngSettings.getClasses());
    try {
      this.srvDatabase.setIsAutocommit(false);
      this.srvDatabase.
        setTransactionIsolation(ISrvDatabase.TRANSACTION_READ_UNCOMMITTED);
      this.srvDatabase.beginTransaction();
      this.logger.info(null, SrvClearDatabase.class, "Start clear database.");
      for (int i = classesArr.size() - 1; i >= 0; i--) {
        Class<?> entityClass = classesArr.get(i);
        this.srvDatabase.executeDelete(entityClass.getSimpleName()
          .toUpperCase(), null);
      }
      this.srvDatabase.commitTransaction();
      Writer htmlWriter = (Writer) pAddParams.get("htmlWriter");
      if (htmlWriter != null) {
        htmlWriter.write("<h4>" + new Date().toString() + ", "
        + SrvClearDatabase.class.getSimpleName()
          + ", database has been cleared" + "</h4>");
      }
      this.logger.info(null, SrvClearDatabase.class, "Finish clear database.");
    } catch (Exception ex) {
      this.srvDatabase.rollBackTransaction();
      throw ex;
    } finally {
      this.srvDatabase.releaseResources();
    }
  }
@Override
  public final void make(
    final Map<String, Object> pAddParams) throws Exception {
    ArrayList<Class<?>> classesArr =
      new ArrayList<Class<?>>(this.mngSettings.getClasses());
    try {
      this.srvDatabase.setIsAutocommit(false);
      this.srvDatabase.
        setTransactionIsolation(ISrvDatabase.TRANSACTION_READ_UNCOMMITTED);
      this.srvDatabase.beginTransaction();
      this.logger.info(null, SrvClearDatabase.class, "Start clear database.");
      for (int i = classesArr.size() - 1; i >= 0; i--) {
        Class<?> entityClass = classesArr.get(i);
        this.srvDatabase.executeDelete(entityClass.getSimpleName()
          .toUpperCase(), null);
      }
      this.srvDatabase.commitTransaction();
      Writer htmlWriter = (Writer) pAddParams.get("htmlWriter");
      if (htmlWriter != null) {
        htmlWriter.write("<h4>" + new Date().toString() + ", "
        + SrvClearDatabase.class.getSimpleName()
          + ", database has been cleared" + "</h4>");
      }
      this.logger.info(null, SrvClearDatabase.class, "Finish clear database.");
    } catch (Exception ex) {
      this.srvDatabase.rollBackTransaction();
      throw ex;
    } finally {
      this.srvDatabase.releaseResources();
    }
  }
@ Override public final void make ( final Map < String , Object > pAddParams ) throws Exception { ArrayList < Class < ? > > classesArr = new ArrayList < Class < ? > > ( this . mngSettings . getClasses ( ) ) ; try { this . srvDatabase . setIsAutocommit ( false ) ; this . srvDatabase . setTransactionIsolation ( ISrvDatabase . TRANSACTION_READ_UNCOMMITTED ) ; this . srvDatabase . beginTransaction ( ) ; this . logger . info ( null , SrvClearDatabase . class , "Start clear database." ) ; for ( int i = classesArr . size ( ) - 1 ; i >= 0 ; i -- ) { Class < ? > entityClass = classesArr . get ( i ) ; this . srvDatabase . executeDelete ( entityClass . getSimpleName ( ) . toUpperCase ( ) , null ) ; } this . srvDatabase . commitTransaction ( ) ; Writer htmlWriter = ( Writer ) pAddParams . get ( "htmlWriter" ) ; if ( htmlWriter != null ) { htmlWriter . write ( "<h4>" + new Date ( ) . toString ( ) + ", " + SrvClearDatabase . class . getSimpleName ( ) + ", database has been cleared" + "</h4>" ) ; } this . logger . info ( null , SrvClearDatabase . class , "Finish clear database." ) ; } catch ( Exception ex ) { this . srvDatabase . rollBackTransaction ( ) ; throw ex ; } finally { this . srvDatabase . releaseResources ( ) ; } }
<p>It will clear current database.</p>
@param pAddParams additional params
@throws Exception - an exception
<p > It will clear current database . < / p >