Example usage for org.springframework.transaction TransactionSystemException TransactionSystemException

List of usage examples for org.springframework.transaction TransactionSystemException TransactionSystemException

Introduction

In this page you can find the example usage for org.springframework.transaction TransactionSystemException TransactionSystemException.

Prototype

public TransactionSystemException(String msg, Throwable cause) 

Source Link

Document

Constructor for TransactionSystemException.

Usage

From source file:org.topazproject.otm.spring.OtmTransactionManager.java

@Override
public void doBegin(Object transaction, TransactionDefinition definition) throws TransactionException {
    try {/*from  w  ww.  j a  v  a  2  s. c  om*/
        Session s = ((TransactionObject) transaction).getSession();
        s.beginTransaction(definition.isReadOnly(), determineTimeout(definition));

        if (definition.isReadOnly() && skipFlushForRoTx) {
            ((TransactionObject) transaction).savedFlushMode = s.getFlushMode();
            s.setFlushMode(Session.FlushMode.commit);
        }
    } catch (OtmException oe) {
        throw new TransactionSystemException("error beginning transaction", oe);
    }
}

From source file:org.topazproject.otm.spring.OtmTransactionManager.java

@Override
public void doCommit(DefaultTransactionStatus status) throws TransactionException {
    TransactionObject txObj = (TransactionObject) status.getTransaction();

    Transaction tx = txObj.getSession().getTransaction();
    if (tx == null)
        throw new TransactionUsageException("no transaction active");

    try {//w  w w . ja v  a  2s .  co m
        tx.commit();
    } catch (OtmException oe) {
        throw new TransactionSystemException("error committing transaction", oe);
    } finally {
        if (txObj.savedFlushMode != null)
            txObj.getSession().setFlushMode(txObj.savedFlushMode);
    }
}

From source file:org.springextensions.neodatis.NeoDatisTransactionManager.java

@Override
protected void doCommit(DefaultTransactionStatus transactionStatus) throws TransactionException {
    NeoDatisTransactionObject transactionObject = (NeoDatisTransactionObject) transactionStatus
            .getTransaction();//from   w  w w . jav a  2  s  .c o m
    logger.debug("Committing NeoDatis transaction on ODB [{}]", transactionObject.getODBHolder().getOdb());
    try {
        transactionObject.getODBHolder().getOdb().commit();
    } catch (Exception e) {
        throw new TransactionSystemException("Could not commit NeoDatis transaction.", e);
    }
}

From source file:org.topazproject.otm.spring.OtmTransactionManager.java

@Override
public void doRollback(DefaultTransactionStatus status) throws TransactionException {
    TransactionObject txObj = (TransactionObject) status.getTransaction();

    Transaction tx = txObj.getSession().getTransaction();
    if (tx == null)
        throw new TransactionUsageException("no transaction active");

    try {//from  w w w.j  a  v a2 s  . com
        tx.rollback();
    } catch (OtmException oe) {
        throw new TransactionSystemException("error rolling back transaction", oe);
    } finally {
        if (clearSessionOnRB)
            txObj.getSession().clear();
        if (txObj.savedFlushMode != null)
            txObj.getSession().setFlushMode(txObj.savedFlushMode);
    }
}

From source file:org.topazproject.otm.spring.OtmTransactionManager.java

@Override
protected void doSetRollbackOnly(DefaultTransactionStatus status) throws TransactionException {
    TransactionObject txObj = (TransactionObject) status.getTransaction();
    try {//w w w . j a  v a  2 s .c  o m
        txObj.setRollbackOnly();
    } catch (OtmException oe) {
        throw new TransactionSystemException("error setting rollback-only", oe);
    }
}

From source file:org.springextensions.neodatis.NeoDatisTransactionManager.java

@Override
protected void doRollback(DefaultTransactionStatus transactionStatus) throws TransactionException {
    NeoDatisTransactionObject transactionObject = (NeoDatisTransactionObject) transactionStatus
            .getTransaction();//w w w  .  jav  a 2s .  co m
    logger.debug("Rolling back NeoDatis transaction on ODB [{}]", transactionObject.getODBHolder().getOdb());
    try {
        transactionObject.getODBHolder().getOdb().rollback();
    } catch (Exception e) {
        throw new TransactionSystemException("Could not rollback NeoDatis transaction.", e);
    }
}

From source file:org.grails.datastore.mapping.transactions.DatastoreTransactionManager.java

@Override
protected void doCommit(DefaultTransactionStatus status) throws TransactionException {
    TransactionObject txObject = (TransactionObject) status.getTransaction();
    final SessionHolder sessionHolder = txObject.getSessionHolder();
    if (status.isDebug()) {
        logger.debug("Committing Datastore transaction on Session [" + sessionHolder.getSession() + "]");
    }//ww  w .ja  va2s. c o  m
    try {
        if (sessionHolder.getSession() != null) {
            sessionHolder.getSession().flush();
        }
        txObject.getTransaction().commit();
    } catch (DataAccessException ex) {
        throw new TransactionSystemException("Could not commit Datastore transaction", ex);
    }
}

From source file:org.grails.datastore.mapping.transactions.DatastoreTransactionManager.java

@Override
protected void doRollback(DefaultTransactionStatus status) throws TransactionException {
    TransactionObject txObject = (TransactionObject) status.getTransaction();
    final SessionHolder sessionHolder = txObject.getSessionHolder();
    if (status.isDebug()) {
        logger.debug("Rolling back Datastore transaction on Session [" + sessionHolder.getSession() + "]");
    }/*from   w w w  .  j  a v a  2  s .  c om*/
    try {
        txObject.getTransaction().rollback();
    } catch (DataAccessException ex) {
        throw new TransactionSystemException("Could not rollback Datastore transaction", ex);
    } finally {
        // Clear all pending inserts/updates/deletes in the Session.
        // Necessary for pre-bound Sessions, to avoid inconsistent state.
        if (sessionHolder.getSession() != null) {
            sessionHolder.getSession().clear();
        }
    }
}

From source file:org.springextensions.db4o.Db4oTransactionManager.java

protected void doCommit(DefaultTransactionStatus status) {
    Db4oTransactionObject txObject = (Db4oTransactionObject) status.getTransaction();
    logger.debug("Committing db4o transaction on object container [{}]",
            txObject.getObjectContainerHolder().getObjectContainer());
    try {/*from  w ww.  ja  v a  2 s .c om*/
        txObject.getObjectContainerHolder().getObjectContainer().commit();
    } catch (Exception ex) {
        // assumably from commit call to the underlying db4o container
        throw new TransactionSystemException("Could not commit db4o transaction", ex);
    }
}