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:net.cbtltd.server.PartyService.java

/**
 * Updates the progress of users towards certain goals.
 * Executed periodically by the RazorServer scheduler. 
 *///  w w w  .  j a  v a  2s  .co  m
public static final void progress() {
    LOG.debug("PartyService progress");
    SqlSession sqlSession = RazorServer.openSession();
    try {
        sqlSession.getMapper(PartyMapper.class).progressdelete();
        sqlSession.getMapper(PartyMapper.class).progressactivitymax();
        sqlSession.getMapper(PartyMapper.class).progressage();
        sqlSession.getMapper(PartyMapper.class).progressagemax();
        sqlSession.getMapper(PartyMapper.class).progressconfirm();
        sqlSession.getMapper(PartyMapper.class).progresscreator();
        sqlSession.getMapper(PartyMapper.class).progresscreatormax();
        //         sqlSession.getMapper(PartyMapper.class).progressvalue();
        //         sqlSession.getMapper(PartyMapper.class).progressvaluemax();
        sqlSession.commit();
    } catch (Throwable x) {
        sqlSession.rollback();
        LOG.error(x.getMessage());
    } finally {
        sqlSession.close();
    }
}

From source file:net.cbtltd.server.PriceService.java

/**
 * Executes the PriceCreate action to create a Price instance.
 *
 * @param sqlSession the current SQL session.
 * @param action the action to be executed.
 * @return the response.//ww w.j a  va  2  s.c  o m
 */
public final Price execute(SqlSession sqlSession, PriceCreate action) {
    try {
        sqlSession.getMapper(PriceMapper.class).create(action);
    } catch (Throwable x) {
        sqlSession.rollback();
        MonitorService.log(x);
    }
    return action;
}

From source file:net.cbtltd.server.PriceService.java

public final Price executeCreate(SqlSession sqlSession, Price action) {
    try {/*  ww  w  .  j av  a 2s .co  m*/
        sqlSession.getMapper(PriceMapper.class).create(action);
    } catch (Throwable x) {
        sqlSession.rollback();
        MonitorService.log(x);
    }
    return action;
}

From source file:net.cbtltd.server.PriceService.java

/**
 * Executes the PriceRead action to read a Price instance.
 *
 * @param sqlSession the current SQL session.
 * @param action the action to be executed.
 * @return the response./*ww w . j  a  v a2s  . c o m*/
 */
public final Price execute(SqlSession sqlSession, PriceRead action) {
    Price price = null;
    try {
        price = sqlSession.getMapper(PriceMapper.class).read(action.getId());
    } catch (Throwable x) {
        sqlSession.rollback();
        MonitorService.log(x);
    }
    return price;
}

From source file:net.cbtltd.server.PriceService.java

public final Price exists(SqlSession sqlSession, PriceRead action) {
    Price price = null;//from   w ww  .  j a  v a2  s  .  co m
    try {
        price = sqlSession.getMapper(PriceMapper.class).exists(action);

    } catch (Throwable x) {
        sqlSession.rollback();
        MonitorService.log(x);
    }
    return price;
}

From source file:net.cbtltd.server.PriceService.java

public final Price exists(SqlSession sqlSession, Price action) {
    Price price = null;/*from w w  w. j  a  va2 s .c om*/
    try {
        price = sqlSession.getMapper(PriceMapper.class).exists(action);

    } catch (Throwable x) {
        sqlSession.rollback();
        MonitorService.log(x);
    }
    return price;
}

From source file:net.cbtltd.server.PriceService.java

/**
 * Executes the PriceUpdate action to update a Price instance.
 *
 * @param sqlSession the current SQL session.
 * @param action the action to be executed.
 * @return the response.//from w  w w .  j av a  2s .c  o m
 */
public final Price execute(SqlSession sqlSession, PriceUpdate action) {
    LOG.debug("PriceUpdate in " + action);
    try {
        Price exists = sqlSession.getMapper(PriceMapper.class).read(action.getId());
        if (action != null && exists != null && action.hashCode() != exists.hashCode()) {
            action.setVersion(new Date());
        }
        sqlSession.getMapper(PriceMapper.class).update(action);
        RelationService.unload(sqlSession, Downloaded.PRICE_DOWNLOAD, action.getEntityid(), null);
        TextService.update(sqlSession, action.getTexts());
        MonitorService.update(sqlSession, Data.Origin.CONSOLE, NameId.Type.Price, action);
    } catch (Throwable x) {
        sqlSession.rollback();
        MonitorService.log(x);
    }
    LOG.debug("PriceUpdate out " + action);
    return action;
}

From source file:net.cbtltd.server.PriceService.java

public final Price executeUpdate(SqlSession sqlSession, Price action) {
    LOG.debug("PriceUpdate in " + action);
    try {//from   ww w. j  a v a  2s. co  m
        Price exists = sqlSession.getMapper(PriceMapper.class).read(action.getId());
        if (action != null && exists != null && action.hashCode() != exists.hashCode()) {
            action.setVersion(new Date());
        }
        sqlSession.getMapper(PriceMapper.class).update(action);
        RelationService.unload(sqlSession, Downloaded.PRICE_DOWNLOAD, action.getEntityid(), null);
        TextService.update(sqlSession, action.getTexts());
        MonitorService.update(sqlSession, Data.Origin.CONSOLE, NameId.Type.Price, action);
    } catch (Throwable x) {
        sqlSession.rollback();
        MonitorService.log(x);
    }
    LOG.debug("PriceUpdate out " + action);
    return action;
}

From source file:net.cbtltd.server.PriceService.java

/**
 * Executes the PriceDelete action to delete a Price instance.
 *
 * @param sqlSession the current SQL session.
 * @param action the action to be executed.
 * @return the response.//from   w  ww . ja  v a 2 s.c  o m
 */
public final Price execute(SqlSession sqlSession, PriceDelete action) {
    try {
        action.setState(Price.FINAL);
        sqlSession.getMapper(PriceMapper.class).update(action);
        RelationService.unload(sqlSession, Downloaded.PRICE_DOWNLOAD, action.getEntityid(), null);
    } catch (Throwable x) {
        sqlSession.rollback();
        MonitorService.log(x);
    }
    return action;
}

From source file:net.cbtltd.server.PriceService.java

/**
 * Executes the PriceValue action to calculate a Price value.
 *
 * @param sqlSession the current SQL session.
 * @param action the action to be executed.
 * @return the double response//from  ww w  .  ja va2  s .c om
 */
public final DoubleResponse execute(SqlSession sqlSession, PriceValue action) {
    DoubleResponse response = new DoubleResponse();
    try {
        response.setValue(sqlSession.getMapper(PriceMapper.class).value(action));
    } catch (Throwable x) {
        sqlSession.rollback();
        MonitorService.log(x);
    }
    return response;
}