Example usage for org.apache.ibatis.session SqlSession rollback

List of usage examples for org.apache.ibatis.session SqlSession rollback

Introduction

In this page you can find the example usage for org.apache.ibatis.session SqlSession rollback.

Prototype

void rollback();

Source Link

Document

Discards pending batch statements and rolls database connection back.

Usage

From source file:ph.fingra.hadoop.dbms.parts.distribution.service.CountryPageviewServiceImpl.java

License:Apache License

public int deleteCountryPageviewWeekByDate(String year, String week) throws Exception {

    SqlSession session = ConnectionFactory.getSession().openSession(ExecutorType.BATCH, false);
    CountryPageviewDao dao = session.getMapper(CountryPageviewDao.class);

    boolean has_error = false;

    try {/* ww  w. j a  va  2 s  .  co m*/
        dao.deleteCountryPageviewWeekByKey(year, week, "", "");
        List<BatchResult> results = session.flushStatements();
        results.clear();
    } catch (Exception e) {
        has_error = true;
        session.rollback();
        session.close();
        throw e;
    } finally {
        if (has_error == false)
            session.commit();
        session.close();
    }

    return (has_error == false) ? 1 : 0;
}

From source file:ph.fingra.hadoop.dbms.parts.distribution.service.CountryPageviewServiceImpl.java

License:Apache License

public int insertBatchCountryPageviewMonth(List<CountryPageviewAll> in_volist) throws Exception {

    if (in_volist == null) {
        return 0;
    }//www  . j  a  v  a 2  s .com

    SqlSession session = ConnectionFactory.getSession().openSession(ExecutorType.BATCH, false);
    CountryPageviewDao dao = session.getMapper(CountryPageviewDao.class);

    boolean has_error = false;

    try {

        if (in_volist != null) {

            Iterator<CountryPageviewAll> it = in_volist.iterator();

            while (it.hasNext()) {
                CountryPageviewAll insert = it.next();
                dao.insertCountryPageviewMonth(insert);
            }
        }

        List<BatchResult> results = session.flushStatements();
        results.clear();
    } catch (Exception e) {
        has_error = true;
        session.rollback();
        session.close();
        throw e;
    } finally {
        if (has_error == false)
            session.commit();
        session.close();
    }

    return (has_error == false) ? 1 : 0;
}

From source file:ph.fingra.hadoop.dbms.parts.distribution.service.CountryPageviewServiceImpl.java

License:Apache License

public int deleteCountryPageviewMonthByDate(String year, String month) throws Exception {

    SqlSession session = ConnectionFactory.getSession().openSession(ExecutorType.BATCH, false);
    CountryPageviewDao dao = session.getMapper(CountryPageviewDao.class);

    boolean has_error = false;

    try {//w w w .j  av a2  s .  c  om
        dao.deleteCountryPageviewMonthByKey(year, month, "", "");
        List<BatchResult> results = session.flushStatements();
        results.clear();
    } catch (Exception e) {
        has_error = true;
        session.rollback();
        session.close();
        throw e;
    } finally {
        if (has_error == false)
            session.commit();
        session.close();
    }

    return (has_error == false) ? 1 : 0;
}

From source file:ph.fingra.hadoop.dbms.parts.distribution.service.CountryServiceImpl.java

License:Apache License

public int insertBatchCountryDay(List<CountryAll> in_volist) throws Exception {

    if (in_volist == null) {
        return 0;
    }//from  w  ww.j a  va 2s .  co  m

    SqlSession session = ConnectionFactory.getSession().openSession(ExecutorType.BATCH, false);
    CountryDao dao = session.getMapper(CountryDao.class);

    boolean has_error = false;

    try {

        if (in_volist != null) {

            Iterator<CountryAll> it = in_volist.iterator();

            while (it.hasNext()) {
                CountryAll insert = it.next();
                dao.insertCountryDay(insert);
            }
        }

        List<BatchResult> results = session.flushStatements();
        results.clear();
    } catch (Exception e) {
        has_error = true;
        session.rollback();
        session.close();
        throw e;
    } finally {
        if (has_error == false)
            session.commit();
        session.close();
    }

    return (has_error == false) ? 1 : 0;
}

From source file:ph.fingra.hadoop.dbms.parts.distribution.service.CountryServiceImpl.java

License:Apache License

public int deleteCountryDayByDate(String year, String month, String day) throws Exception {

    SqlSession session = ConnectionFactory.getSession().openSession(ExecutorType.BATCH, false);
    CountryDao dao = session.getMapper(CountryDao.class);

    boolean has_error = false;

    try {/*  w w w.  j  a v  a2 s  .  c  o  m*/
        dao.deleteCountryDayByKey(year, month, day, "", "");
        List<BatchResult> results = session.flushStatements();
        results.clear();
    } catch (Exception e) {
        has_error = true;
        session.rollback();
        session.close();
        throw e;
    } finally {
        if (has_error == false)
            session.commit();
        session.close();
    }

    return (has_error == false) ? 1 : 0;
}

From source file:ph.fingra.hadoop.dbms.parts.distribution.service.CountryServiceImpl.java

License:Apache License

public int insertBatchCountryWeek(List<CountryAll> in_volist) throws Exception {

    if (in_volist == null) {
        return 0;
    }/*from w ww.  j  a  v  a 2 s .  c om*/

    SqlSession session = ConnectionFactory.getSession().openSession(ExecutorType.BATCH, false);
    CountryDao dao = session.getMapper(CountryDao.class);

    boolean has_error = false;

    try {

        if (in_volist != null) {

            Iterator<CountryAll> it = in_volist.iterator();

            while (it.hasNext()) {
                CountryAll insert = it.next();
                dao.insertCountryWeek(insert);
            }
        }

        List<BatchResult> results = session.flushStatements();
        results.clear();
    } catch (Exception e) {
        has_error = true;
        session.rollback();
        session.close();
        throw e;
    } finally {
        if (has_error == false)
            session.commit();
        session.close();
    }

    return (has_error == false) ? 1 : 0;
}

From source file:ph.fingra.hadoop.dbms.parts.distribution.service.CountryServiceImpl.java

License:Apache License

public int deleteCountryWeekByDate(String year, String week) throws Exception {

    SqlSession session = ConnectionFactory.getSession().openSession(ExecutorType.BATCH, false);
    CountryDao dao = session.getMapper(CountryDao.class);

    boolean has_error = false;

    try {/*  w w  w  .j a v  a2s. c  om*/
        dao.deleteCountryWeekByKey(year, week, "", "");
        List<BatchResult> results = session.flushStatements();
        results.clear();
    } catch (Exception e) {
        has_error = true;
        session.rollback();
        session.close();
        throw e;
    } finally {
        if (has_error == false)
            session.commit();
        session.close();
    }

    return (has_error == false) ? 1 : 0;
}

From source file:ph.fingra.hadoop.dbms.parts.distribution.service.CountryServiceImpl.java

License:Apache License

public int insertBatchCountryMonth(List<CountryAll> in_volist) throws Exception {

    if (in_volist == null) {
        return 0;
    }/*from  w w w. j a  va 2  s. c  o  m*/

    SqlSession session = ConnectionFactory.getSession().openSession(ExecutorType.BATCH, false);
    CountryDao dao = session.getMapper(CountryDao.class);

    boolean has_error = false;

    try {

        if (in_volist != null) {

            Iterator<CountryAll> it = in_volist.iterator();

            while (it.hasNext()) {
                CountryAll insert = it.next();
                dao.insertCountryMonth(insert);
            }
        }

        List<BatchResult> results = session.flushStatements();
        results.clear();
    } catch (Exception e) {
        has_error = true;
        session.rollback();
        session.close();
        throw e;
    } finally {
        if (has_error == false)
            session.commit();
        session.close();
    }

    return (has_error == false) ? 1 : 0;
}

From source file:ph.fingra.hadoop.dbms.parts.distribution.service.CountryServiceImpl.java

License:Apache License

public int deleteCountryMonthByDate(String year, String month) throws Exception {

    SqlSession session = ConnectionFactory.getSession().openSession(ExecutorType.BATCH, false);
    CountryDao dao = session.getMapper(CountryDao.class);

    boolean has_error = false;

    try {// w w  w  .j av  a2  s  .c  om
        dao.deleteCountryMonthByKey(year, month, "", "");
        List<BatchResult> results = session.flushStatements();
        results.clear();
    } catch (Exception e) {
        has_error = true;
        session.rollback();
        session.close();
        throw e;
    } finally {
        if (has_error == false)
            session.commit();
        session.close();
    }

    return (has_error == false) ? 1 : 0;
}

From source file:ph.fingra.hadoop.dbms.parts.distribution.service.CountrySessionlengthSectionServiceImpl.java

License:Apache License

public int insertBatchCountrySessionlengthSectionDay(List<CountrySessionlengthSectionAll> in_volist)
        throws Exception {

    if (in_volist == null) {
        return 0;
    }//from w w w .ja v a 2  s  . c  om

    SqlSession session = ConnectionFactory.getSession().openSession(ExecutorType.BATCH, false);
    CountrySessionlengthSectionDao dao = session.getMapper(CountrySessionlengthSectionDao.class);

    boolean has_error = false;

    try {

        if (in_volist != null) {

            Iterator<CountrySessionlengthSectionAll> it = in_volist.iterator();

            while (it.hasNext()) {
                CountrySessionlengthSectionAll insert = it.next();
                dao.insertCountrySessionlengthSectionDay(insert);
            }
        }

        List<BatchResult> results = session.flushStatements();
        results.clear();
    } catch (Exception e) {
        has_error = true;
        session.rollback();
        session.close();
        throw e;
    } finally {
        if (has_error == false)
            session.commit();
        session.close();
    }

    return (has_error == false) ? 1 : 0;
}