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.CountrySessionlengthSectionServiceImpl.java

License:Apache License

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

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

    boolean has_error = false;

    try {// w  w w. j  a  va2 s  . c o m
        dao.deleteCountrySessionlengthSectionDayByKey(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.CountrySessionlengthSectionServiceImpl.java

License:Apache License

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

    if (in_volist == null) {
        return 0;
    }/*from www  . j  av a2  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.insertCountrySessionlengthSectionWeek(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.CountrySessionlengthSectionServiceImpl.java

License:Apache License

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

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

    boolean has_error = false;

    try {//from  w ww  . j  ava2s . c o  m
        dao.deleteCountrySessionlengthSectionWeekByKey(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.CountrySessionlengthSectionServiceImpl.java

License:Apache License

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

    if (in_volist == null) {
        return 0;
    }// w ww  .  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.insertCountrySessionlengthSectionMonth(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.CountrySessionlengthSectionServiceImpl.java

License:Apache License

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

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

    boolean has_error = false;

    try {// www  .  j  av  a  2 s . c  om
        dao.deleteCountrySessionlengthSectionMonthByKey(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.CountrySessionlengthServiceImpl.java

License:Apache License

public int insertBatchCountrySessionlengthDay(List<CountrySessionlengthAll> in_volist) throws Exception {

    if (in_volist == null) {
        return 0;
    }/*from   w  w w .  ja v a2  s. co  m*/

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

    boolean has_error = false;

    try {

        if (in_volist != null) {

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

            while (it.hasNext()) {
                CountrySessionlengthAll insert = it.next();
                dao.insertCountrySessionlengthDay(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.CountrySessionlengthServiceImpl.java

License:Apache License

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

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

    boolean has_error = false;

    try {/*w ww. j  a  v a2 s.  c o m*/
        dao.deleteCountrySessionlengthDayByKey(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.CountrySessionlengthServiceImpl.java

License:Apache License

public int insertBatchCountrySessionlengthWeek(List<CountrySessionlengthAll> in_volist) throws Exception {

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

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

    boolean has_error = false;

    try {

        if (in_volist != null) {

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

            while (it.hasNext()) {
                CountrySessionlengthAll insert = it.next();
                dao.insertCountrySessionlengthWeek(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.CountrySessionlengthServiceImpl.java

License:Apache License

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

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

    boolean has_error = false;

    try {/*from w w  w .j av a2 s  .  c o m*/
        dao.deleteCountrySessionlengthWeekByKey(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.CountrySessionlengthServiceImpl.java

License:Apache License

public int insertBatchCountrySessionlengthMonth(List<CountrySessionlengthAll> in_volist) throws Exception {

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

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

    boolean has_error = false;

    try {

        if (in_volist != null) {

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

            while (it.hasNext()) {
                CountrySessionlengthAll insert = it.next();
                dao.insertCountrySessionlengthMonth(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;
}