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

License:Apache License

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

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

    boolean has_error = false;

    try {/*from w w w  .  j a va 2s .co m*/
        dao.deleteCountryTimeWeekByKey(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.CountryTimeServiceImpl.java

License:Apache License

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

    if (in_volist == null) {
        return 0;
    }//  w w w . jav  a2 s.  co  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.insertCountryTimeMonth(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 deleteCountryTimeMonthByDate(String year, String month) throws Exception {

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

    boolean has_error = false;

    try {/*from  w w  w  .  j av a  2 s.co  m*/
        dao.deleteCountryTimeMonthByKey(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.DeviceServiceImpl.java

License:Apache License

public int insertBatchDeviceDay(List<DeviceAll> in_volist) throws Exception {

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

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

    boolean has_error = false;

    try {

        if (in_volist != null) {

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

            while (it.hasNext()) {
                DeviceAll insert = it.next();
                dao.insertDeviceDay(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.DeviceServiceImpl.java

License:Apache License

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

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

    boolean has_error = false;

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

License:Apache License

public int insertBatchDeviceWeek(List<DeviceAll> in_volist) throws Exception {

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

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

    boolean has_error = false;

    try {

        if (in_volist != null) {

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

            while (it.hasNext()) {
                DeviceAll insert = it.next();
                dao.insertDeviceWeek(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.DeviceServiceImpl.java

License:Apache License

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

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

    boolean has_error = false;

    try {//from w  ww  . j ava2s  . co m
        dao.deleteDeviceWeekByKey(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.DeviceServiceImpl.java

License:Apache License

public int insertBatchDeviceMonth(List<DeviceAll> in_volist) throws Exception {

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

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

    boolean has_error = false;

    try {

        if (in_volist != null) {

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

            while (it.hasNext()) {
                DeviceAll insert = it.next();
                dao.insertDeviceMonth(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.DeviceServiceImpl.java

License:Apache License

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

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

    boolean has_error = false;

    try {/*w  w  w  .  java2s  .  co m*/
        dao.deleteDeviceMonthByKey(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.LanguageServiceImpl.java

License:Apache License

public int insertBatchLanguageDay(List<LanguageAll> 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);
    LanguageDao dao = session.getMapper(LanguageDao.class);

    boolean has_error = false;

    try {

        if (in_volist != null) {

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

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