Package se.unlogic.standardutils.dao

Examples of se.unlogic.standardutils.dao.TransactionHandler


      return;
    }

    Integer zoneID = ((DBSecondaryZone)zone).getZoneID();

    TransactionHandler transactionHandler = null;

    try {
      transactionHandler = zoneDAO.createTransaction();

      DBZone dbZone = this.zoneDAO.get(new HighLevelQuery<DBZone>(this.zoneIDQueryParameterFactory.getParameter(zoneID),(Field)null),transactionHandler);


      if(dbZone == null){

        log.warn("Unable to find secondary zone with zoneID " + zoneID + " in DB, ignoring zone update");

        return;
      }

      dbZone.parse(zone.getZoneCopy(), true);

      zoneDAO.update(dbZone,transactionHandler, null);

      recordDAO.delete(new HighLevelQuery<DBRecord>(recordZoneQueryParameterFactory.getParameter(dbZone),(Field)null), transactionHandler);

      if(dbZone.getRecords() != null){

        for(DBRecord dbRecord : dbZone.getRecords()){

          dbRecord.setZone(dbZone);

          this.recordDAO.add(dbRecord, transactionHandler, null);
        }
      }

      transactionHandler.commit();

      log.debug("Changes in seconday zone " + dbZone + " saved");

    } catch (SQLException e) {
View Full Code Here


      return;
    }

    Integer zoneID = ((DBSecondaryZone)zone).getZoneID();

    TransactionHandler transactionHandler = null;

    try {
      transactionHandler = zoneDAO.createTransaction();

      DBZone dbZone = this.zoneDAO.get(new HighLevelQuery<DBZone>(this.zoneIDQueryParameterFactory.getParameter(zoneID), (Field)null),transactionHandler);

      if(dbZone == null){

        log.warn("Unable to find secondary zone with zoneID " + zoneID + " in DB, ignoring zone update");

        return;
      }

      dbZone.parse(zone.getZoneCopy(), true);

      zoneDAO.update(dbZone,transactionHandler, null);

      transactionHandler.commit();

      log.debug("Changes in seconday zone " + dbZone + " saved");

    } catch (SQLException e) {
View Full Code Here

  }
 
  public void executeScript(String script) throws SQLException {

    TransactionHandler transactionHandler = null;
    UpdateQuery updateQuery;

    ScriptUtility scriptUtility = new MySQLScriptUtility();
    List<String> statements = scriptUtility.getStatements(script);
   
    try {
     
      transactionHandler = new TransactionHandler(this.dataSource);

      for(String query : statements) {
        updateQuery = transactionHandler.getUpdateQuery(query.toString());
        updateQuery.executeUpdate();
      }
     
      transactionHandler.commit();

    } finally {

      TransactionHandler.autoClose(transactionHandler);
   
View Full Code Here

    SimpleAnnotatedDAOFactory annotatedDAOFactory = new SimpleAnnotatedDAOFactory();
    AnnotatedDAO<DBZone> zoneDAO  = new AnnotatedDAO<DBZone>(dataSource,DBZone.class, annotatedDAOFactory);
    AnnotatedDAO<DBRecord> recordDAO  = new AnnotatedDAO<DBRecord>(dataSource,DBRecord.class, annotatedDAOFactory);

    TransactionHandler transactionHandler = zoneDAO.createTransaction();

    try{

      for(DBZone zone : dbZones){

        System.out.println("Storing zone " + zone + "...");

        zoneDAO.add(zone, transactionHandler, null);

        for(DBRecord dbRecord : zone.getRecords()){

          System.out.println("Storing record " + dbRecord + "...");

          dbRecord.setZone(zone);

          recordDAO.add(dbRecord, transactionHandler, null);
        }
      }

      transactionHandler.commit();

    }catch(Throwable e){

      transactionHandler.abort();
     
      throw e;
    }
  }
View Full Code Here

    SimpleAnnotatedDAOFactory annotatedDAOFactory = new SimpleAnnotatedDAOFactory();
    AnnotatedDAO<DBZone> zoneDAO  = new AnnotatedDAO<DBZone>(dataSource,DBZone.class, annotatedDAOFactory);
    AnnotatedDAO<DBRecord> recordDAO  = new AnnotatedDAO<DBRecord>(dataSource,DBRecord.class, annotatedDAOFactory);

    TransactionHandler transactionHandler = zoneDAO.createTransaction();

    try{

      for(DBZone zone : dbZones){

        System.out.println("Storing zone " + zone + "...");

        zoneDAO.add(zone, transactionHandler, null);

        for(DBRecord dbRecord : zone.getRecords()){

          System.out.println("Storing record " + dbRecord + "...");

          dbRecord.setZone(zone);

          recordDAO.add(dbRecord, transactionHandler, null);
        }
      }

      transactionHandler.commit();

    }catch(Throwable e){

      transactionHandler.abort();
     
      throw e;
    }
  }
View Full Code Here

  }
 
  public void executeScript(String script) throws SQLException {

    TransactionHandler transactionHandler = null;
    UpdateQuery updateQuery;

    ScriptUtility scriptUtility = new MySQLScriptUtility();
    List<String> statements = scriptUtility.getStatements(script);
   
    try {
     
      transactionHandler = new TransactionHandler(this.dataSource);

      for(String query : statements) {
        updateQuery = transactionHandler.getUpdateQuery(query.toString());
        updateQuery.executeUpdate();
      }
     
      transactionHandler.commit();

    } finally {

      TransactionHandler.autoClose(transactionHandler);
   
View Full Code Here

      return;
    }

    Integer zoneID = ((DBSecondaryZone)zone).getZoneID();

    TransactionHandler transactionHandler = null;

    try {
      transactionHandler = zoneDAO.createTransaction();

      DBZone dbZone = this.zoneDAO.get(new HighLevelQuery<DBZone>(this.zoneIDQueryParameterFactory.getParameter(zoneID),(Field)null),transactionHandler);


      if(dbZone == null){

        log.warn("Unable to find secondary zone with zoneID " + zoneID + " in DB, ignoring zone update");

        return;
      }

      dbZone.parse(zone.getZoneCopy(), true);

      zoneDAO.update(dbZone,transactionHandler, null);

      recordDAO.delete(new HighLevelQuery<DBRecord>(recordZoneQueryParameterFactory.getParameter(dbZone),(Field)null), transactionHandler);

      if(dbZone.getRecords() != null){

        for(DBRecord dbRecord : dbZone.getRecords()){

          dbRecord.setZone(dbZone);

          this.recordDAO.add(dbRecord, transactionHandler, null);
        }
      }

      transactionHandler.commit();

      log.debug("Changes in seconday zone " + dbZone + " saved");

    } catch (SQLException e) {
View Full Code Here

      return;
    }

    Integer zoneID = ((DBSecondaryZone)zone).getZoneID();

    TransactionHandler transactionHandler = null;

    try {
      transactionHandler = zoneDAO.createTransaction();

      DBZone dbZone = this.zoneDAO.get(new HighLevelQuery<DBZone>(this.zoneIDQueryParameterFactory.getParameter(zoneID), (Field)null),transactionHandler);

      if(dbZone == null){

        log.warn("Unable to find secondary zone with zoneID " + zoneID + " in DB, ignoring zone update");

        return;
      }

      dbZone.parse(zone.getZoneCopy(), true);

      zoneDAO.update(dbZone,transactionHandler, null);

      transactionHandler.commit();

      log.debug("Changes in seconday zone " + dbZone + " saved");

    } catch (SQLException e) {
View Full Code Here

TOP

Related Classes of se.unlogic.standardutils.dao.TransactionHandler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.