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

License:Apache License

public int deleteCountrySessionlengthMonthByDate(String year, String month) 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 a  2s. c  o m*/
        dao.deleteCountrySessionlengthMonthByKey(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.CountrySessionServiceImpl.java

License:Apache License

public int insertBatchCountrySessionDay(List<CountrySessionAll> in_volist) throws Exception {

    if (in_volist == null) {
        return 0;
    }/*  www. ja v  a2  s. c  om*/

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

    boolean has_error = false;

    try {

        if (in_volist != null) {

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

            while (it.hasNext()) {
                CountrySessionAll insert = it.next();
                dao.insertCountrySessionDay(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.CountrySessionServiceImpl.java

License:Apache License

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

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

    boolean has_error = false;

    try {/* w w  w.ja  va  2s .c o  m*/
        dao.deleteCountrySessionDayByKey(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.CountrySessionServiceImpl.java

License:Apache License

public int insertBatchCountrySessionWeek(List<CountrySessionAll> in_volist) throws Exception {

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

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

    boolean has_error = false;

    try {

        if (in_volist != null) {

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

            while (it.hasNext()) {
                CountrySessionAll insert = it.next();
                dao.insertCountrySessionWeek(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.CountrySessionServiceImpl.java

License:Apache License

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

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

    boolean has_error = false;

    try {/*from   w  ww  . java 2 s . c o  m*/
        dao.deleteCountrySessionWeekByKey(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.CountrySessionServiceImpl.java

License:Apache License

public int insertBatchCountrySessionMonth(List<CountrySessionAll> in_volist) throws Exception {

    if (in_volist == null) {
        return 0;
    }/*from  w ww  . j  ava  2s.  com*/

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

    boolean has_error = false;

    try {

        if (in_volist != null) {

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

            while (it.hasNext()) {
                CountrySessionAll insert = it.next();
                dao.insertCountrySessionMonth(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.CountrySessionServiceImpl.java

License:Apache License

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

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

    boolean has_error = false;

    try {//from   w w  w  .  j  ava 2 s.  c o m
        dao.deleteCountrySessionMonthByKey(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.CountryTimeServiceImpl.java

License:Apache License

public int insertBatchCountryTimeDay(List<CountryTimeAll> in_volist) throws Exception {

    if (in_volist == null) {
        return 0;
    }//from w  w  w.j  ava2s  .  c o  m

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

    boolean has_error = false;

    try {

        if (in_volist != null) {

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

            while (it.hasNext()) {
                CountryTimeAll insert = it.next();
                dao.insertCountryTimeDay(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.CountryTimeServiceImpl.java

License:Apache License

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

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

    boolean has_error = false;

    try {/*from ww w  .  j  a v  a  2 s.  c o  m*/
        dao.deleteCountryTimeDayByKey(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.CountryTimeServiceImpl.java

License:Apache License

public int insertBatchCountryTimeWeek(List<CountryTimeAll> in_volist) throws Exception {

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

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

    boolean has_error = false;

    try {

        if (in_volist != null) {

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

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