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 YieldTable action to read a Yield management table.
 *
 * @param sqlSession the current SQL session.
 * @param action the action to be executed.
 * @return the response./*from w w w  .  ja  va  2s . c  om*/
 */
public final Table<Yield> execute(SqlSession sqlSession, YieldTable action) {
    Table<Yield> table = new Table<Yield>();
    try {
        table.setValue(sqlSession.getMapper(YieldMapper.class).listbyentity(action));
    } catch (Throwable x) {
        sqlSession.rollback();
        MonitorService.log(x);
    }
    return table;
}

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

/**
 * Executes the PriceCurrency action to read a list of currency NameId instances from the price table.
 *
 * @param sqlSession the current SQL session.
 * @param action the action to be executed.
 * @return the response.// w w w .j  a v a2 s .c o m
 */
public final Table<NameId> execute(SqlSession sqlSession, PriceCurrency action) {
    Table<NameId> table = new Table<NameId>();
    try {
        table.setValue(sqlSession.getMapper(PriceMapper.class).pricecurrency(action));
    } catch (Throwable x) {
        sqlSession.rollback();
        MonitorService.log(x);
    }
    return table;
}

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

/**
 * Executes the PriceType action to read a list of price type NameId instances.
 *
 * @param sqlSession the current SQL session.
 * @param action the action to be executed.
 * @return the response.//from w w  w . jav a2 s.  c om
 */
public final Table<NameId> execute(SqlSession sqlSession, PriceType action) {
    Table<NameId> table = new Table<NameId>();
    try {
        table.setValue(sqlSession.getMapper(PriceMapper.class).pricetype(action));
    } catch (Throwable x) {
        sqlSession.rollback();
        MonitorService.log(x);
    }
    return table;
}

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

/**
 * Executes the PriceUnit action to read a list of price unit NameId instances.
 *
 * @param sqlSession the current SQL session.
 * @param action the action to be executed.
 * @return the response.//  w ww .ja  v a 2  s .  co m
 */
public final Table<NameId> execute(SqlSession sqlSession, PriceUnit action) {
    Table<NameId> table = new Table<NameId>();
    try {
        table.setValue(sqlSession.getMapper(PriceMapper.class).priceunit(action));
    } catch (Throwable x) {
        sqlSession.rollback();
        MonitorService.log(x);
    }
    return table;
}

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

/**
 * Executes the PriceNameId action to read a list of price NameId instances.
 *
 * @param sqlSession the current SQL session.
 * @param action the action to be executed.
 * @return the response.//w  w  w  . j  a va  2  s  .  c  o m
 */
public final Table<NameId> execute(SqlSession sqlSession, NameIdAction action) {
    Table<NameId> table = new Table<NameId>();
    try {
        if (action.isSuggested()) {
            table.setValue(sqlSession.getMapper(PriceMapper.class).nameidbyid(action));
        } else {
            table.setValue(sqlSession.getMapper(PriceMapper.class).nameidbyname(action));
        }
    } catch (Throwable x) {
        sqlSession.rollback();
        MonitorService.log(x);
    }
    return table;
}

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

/**
 * Executes the ProductCreate action to create a Product instance.
 *
 * @param sqlSession the current SQL session.
 * @param action the action to be executed.
 * @return the response./*from   ww  w  . j ava2 s  . co  m*/
 */
public final Product execute(SqlSession sqlSession, ProductCreate action) {
    try {
        sqlSession.getMapper(ProductMapper.class).create(action);
        action.setProductImageRootLocation(ImageService.getProductImageLocation(sqlSession, action));
        RelationService.create(sqlSession, Relation.ORGANIZATION_PRODUCT, action.getOrganizationid(),
                action.getId());
    } catch (Throwable x) {
        sqlSession.rollback();
        MonitorService.log(x);
    }
    return action;
}

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

/**
 * Executes the ProductExists action to read a Product instance if it exists and create it if it does not.
 *
 * @param sqlSession the current SQL session.
 * @param action the action to be executed.
 * @return the response.//  w ww .j a  v a 2 s .co m
 */
public final Product execute(SqlSession sqlSession, ProductExists action) {
    Product product = null;
    try {
        product = sqlSession.getMapper(ProductMapper.class).exists(action);
        if (product != null) {
            RelationService.create(sqlSession, Relation.ORGANIZATION_PRODUCT, action.getOrganizationid(),
                    product.getId());
        }
    } catch (Throwable x) {
        sqlSession.rollback();
        MonitorService.log(x);
    }
    return product;
}

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

/**
 * Executes the ProductRead action to read a rich Product instance for an application.
 *
 * @param sqlSession the current SQL session.
 * @param action the action to be executed.
 * @return the response./*www. jav  a  2 s  .  c om*/
 */
public final Product execute(SqlSession sqlSession, ProductRead action) {
    Product product = null;
    try {
        product = sqlSession.getMapper(ProductMapper.class).read(action.getId());
        product.setFiles(sqlSession.getMapper(TextMapper.class).productfilenameid(product.getId()));
        //         product.setImageurls(sqlSession.getMapper(TextMapper.class).imageidsbynameid(new NameId(NameId.Type.Product.name(), action.getId())));
        product.setImageurls(
                (ArrayList<String>) ImageService.getProductThumbAndOriginImageURLs(sqlSession, action.getId()));
        product.setProductImageRootLocation(ImageService.getProductImageLocation(sqlSession, product));
        product.setValues(RelationService.read(sqlSession, Relation.PRODUCT_VALUE, product.getId(), null));
        product.setAttributemap(RelationService.readMap(sqlSession, Relation.PRODUCT_ATTRIBUTE, product.getId(),
                Attribute.PROPERTY));
    } catch (Throwable x) {
        sqlSession.rollback();
        MonitorService.log(x);
    }
    LOG.debug("ProductRead " + product);
    return product;
}

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

/**
 * Executes the WidgetProduct action to read a basic Product instance for a widget.
 *
 * @param sqlSession the current SQL session.
 * @param action the action to be executed.
 * @return the response.//from ww  w.  j  a  va 2 s  . co  m
 */
public final Product execute(SqlSession sqlSession, WidgetProduct action) {
    Product product = null;
    try {
        product = sqlSession.getMapper(ProductMapper.class).read(action.getId());
        //         product.setImageurls(sqlSession.getMapper(TextMapper.class).imageidsbynameid(new NameId(NameId.Type.Product.name(), action.getId())));
        product.setImageurls(
                (ArrayList<String>) ImageService.getProductThumbnailImageURLs(sqlSession, action.getId()));
        product.setProductImageRootLocation(ImageService.getProductImageLocation(sqlSession, product));
    } catch (Throwable x) {
        sqlSession.rollback();
        MonitorService.log(x);
    }
    return product;
}

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

/**
 * Executes the ProductUpdate action to update a Product instance.
 * Updates related object graph./* w  w w  . ja  va2s  .c om*/
 * Deletes related download relations to allow download of potentially changed objects.
 *
 * @param sqlSession the current SQL session.
 * @param action the action to be executed.
 * @return the response.
 */
public final Product execute(SqlSession sqlSession, ProductUpdate action) {
    try {
        Product exists = sqlSession.getMapper(ProductMapper.class).read(action.getId());
        MonitorService.update(sqlSession, Data.Origin.CONSOLE, NameId.Type.Product, action);
        if (action != null && exists != null && action.hashCode() != exists.hashCode()) {
            action.setVersion(new Date());
        }
        sqlSession.getMapper(ProductMapper.class).update(action);
        action.setImageurls(
                (ArrayList<String>) ImageService.getProductThumbAndOriginImageURLs(sqlSession, action.getId()));
        action.setProductImageRootLocation(ImageService.getProductImageLocation(sqlSession, action));
        RelationService.replace(sqlSession, Relation.PRODUCT_VALUE, action.getId(), action.getValues());
        RelationService.replace(sqlSession, Relation.PRODUCT_ATTRIBUTE, action.getId(),
                action.getAttributemap());
        RelationService.unload(sqlSession, Downloaded.PRODUCT_DOWNLOAD, action.getId(), null);
        TextService.update(sqlSession, action.getTexts());
        MonitorService.update(sqlSession, Data.Origin.CONSOLE, NameId.Type.Product, action);
    } catch (Throwable x) {
        sqlSession.rollback();
        MonitorService.log(x);
    }
    return action;
}