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

/**
 * Executes the PriceTable action to read a Price table.
 *
 * @param sqlSession the current SQL session.
 * @param action the action to be executed.
 * @return the response./* w ww.java 2s .co  m*/
 */
public final Table<Price> execute(SqlSession sqlSession, PriceTable action) {
    LOG.debug("PriceTable " + action);
    Table<Price> table = new Table<Price>();
    try {
        table.setDatasize(sqlSession.getMapper(PriceMapper.class).count(action));
        table.setValue(sqlSession.getMapper(PriceMapper.class).list(action));
    } catch (Throwable x) {
        sqlSession.rollback();
        MonitorService.log(x);
    }
    LOG.debug("\nPriceTable " + table);
    return table;
}

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

/**
 * Executes the PriceTableConverted action to read a Price table converted to a target currency.
 *
 * @param sqlSession the current SQL session.
 * @param action the action to be executed.
 * @return the response./*from   w  ww  . j  a  v  a2 s. co  m*/
 */
public final Table<Price> execute(SqlSession sqlSession, PriceTableConverted action) {
    LOG.debug("PriceTableConverted " + action);
    Table<Price> table = new Table<Price>();
    try {
        table.setDatasize(sqlSession.getMapper(PriceMapper.class).count(action));
        ArrayList<Price> prices = sqlSession.getMapper(PriceMapper.class).list(action);
        for (Price price : prices) {
            Double exchangerate = WebService.getRate(sqlSession, price.getCurrency(), action.getCurrency(),
                    new Date());
            price.setValue(price.getValue() * exchangerate);
            price.setMinimum(price.getMinimum() * exchangerate);
            price.setCurrency(action.getCurrency());
        }
        table.setValue(prices);
    } catch (Throwable x) {
        sqlSession.rollback();
        MonitorService.log(x);
    }
    LOG.debug("PriceTableConverted " + table);
    return table;
}

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

/**
 * Executes the ProductFeatureTable action to read a feature table of a property.
 *
 * @param sqlSession the current SQL session.
 * @param action the action to be executed.
 * @return the response.//from  w  w  w. j  ava2 s . c  o  m
 */
public final Table<Price> execute(SqlSession sqlSession, ProductFeatureTable action) {
    Table<Price> response = new Table<Price>();
    try {
        response.setDatasize(sqlSession.getMapper(PriceMapper.class).productfeaturecount(action));
        response.setValue(sqlSession.getMapper(PriceMapper.class).productfeaturelist(action));
    } catch (Throwable x) {
        sqlSession.rollback();
        MonitorService.log(x);
    }
    return response;
}

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

/**
 * Executes the QuoteDetailTable action to read the quote detail table of a reservation.
 *
 * @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 Table<Price> execute(SqlSession sqlSession, QuoteDetailTable action) {
    Table<Price> response = new Table<Price>();
    try {
        response.setValue(sqlSession.getMapper(PriceMapper.class).quotedetail(action.getEntityid()));
    } catch (Throwable x) {
        sqlSession.rollback();
        MonitorService.log(x);
    }
    return response;
}

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

/**
 * Executes the PriceWidgetTable action to read a Price table for the price widget.
 * The action get the supplier from the specified product instance.
 *
 * @param sqlSession the current SQL session.
 * @param action the action to be executed.
 * @return the response.//from ww w  .  j a  v a 2  s. c  o  m
 */
public final Table<Price> execute(SqlSession sqlSession, WidgetPriceTable action) {
    Table<Price> table = new Table<Price>();
    try {
        Product product = sqlSession.getMapper(ProductMapper.class).read(action.getEntityid());
        action.setPartyid(product.getSupplierid());
        ArrayList<Price> prices = sqlSession.getMapper(PriceMapper.class).list(action);
        LOG.debug("WidgetPriceTable action " + action + "\nprices " + prices);
        for (Price price : prices) {
            Double exchangerate = WebService.getRate(sqlSession, price.getCurrency(), action.getCurrency(),
                    new Date());
            price.setValue(price.getValue() * exchangerate);
            price.setMinimum(price.getMinimum() * exchangerate);
            price.setCurrency(action.getCurrency());
        }
        table.setValue(prices);
    } catch (Throwable x) {
        sqlSession.rollback();
        MonitorService.log(x);
    }
    LOG.debug("WidgetPriceTable out " + table);
    return table;
}

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

/**
 * Executes the ServicePriceTable action to read a service Price table.
 *
 * @param sqlSession the current SQL session.
 * @param action the action to be executed.
 * @return the response.//from   www. j a  v a2s.c  om
 */
public final Table<Price> execute(SqlSession sqlSession, ServicePriceTable action) {
    Table<Price> response = new Table<Price>();
    try {
        response.setDatasize(sqlSession.getMapper(PriceMapper.class).servicecount(action));
        response.setValue(sqlSession.getMapper(PriceMapper.class).servicelist(action));
    } catch (Throwable x) {
        sqlSession.rollback();
        MonitorService.log(x);
    }
    return response;
}

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

/**
 * Executes the YieldCreate action to create a Yield management instance.
 *
 * @param sqlSession the current SQL session.
 * @param action the action to be executed.
 * @return the yield//from ww w  . jav  a  2  s.c o  m
 */
public final Yield execute(SqlSession sqlSession, YieldCreate action) {
    try {
        sqlSession.getMapper(YieldMapper.class).create(action);
    } catch (Throwable x) {
        sqlSession.rollback();
        MonitorService.log(x);
    }
    return action;
}

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

/**
 * Executes the YieldRead action to read a Yield management instance.
 *
 * @param sqlSession the current SQL session.
 * @param action the action to be executed.
 * @return the yield//from  w  w w  . j ava  2s.com
 */
public final Yield execute(SqlSession sqlSession, YieldRead action) {
    Yield yield = null;
    try {
        yield = sqlSession.getMapper(YieldMapper.class).read(action.getId());
    } catch (Throwable x) {
        sqlSession.rollback();
        MonitorService.log(x);
    }
    return yield;
}

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

/**
 * Executes the YieldUpdate action to update a Yield management instance.
 *
 * @param sqlSession the current SQL session.
 * @param action the action to be executed.
 * @return the yield/* w  ww .jav  a2  s.com*/
 */
public final Yield execute(SqlSession sqlSession, YieldUpdate action) {
    try {
        sqlSession.getMapper(YieldMapper.class).update(action);
    } catch (Throwable x) {
        sqlSession.rollback();
        MonitorService.log(x);
    }
    return action;
}

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

/**
 * Executes the YieldDelete action to delete a Yield management instance.
 *
 * @param sqlSession the current SQL session.
 * @param action the action to be executed.
 * @return the yield//from  ww  w. j  a v  a  2  s  .c  o m
 */
public final Yield execute(SqlSession sqlSession, YieldDelete action) {
    try {
        action.setState(Yield.FINAL);
        sqlSession.getMapper(YieldMapper.class).update(action);
    } catch (Throwable x) {
        sqlSession.rollback();
        MonitorService.log(x);
    }
    return action;
}