org.springframework.transaction.TransactionStatus

Here are the examples of the java api org.springframework.transaction.TransactionStatus taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

237 Examples 7

19 Source : SpringTransaction.java
with Apache License 2.0
from yuanmabiji

/**
 * Adapts a Spring transaction for JOOQ.
 *
 * @author Lukas Eder
 * @author Andreas Ahlenstorf
 * @author Phillip Webb
 */
clreplaced SpringTransaction implements Transaction {

    // Based on the jOOQ-spring-example from https://github.com/jOOQ/jOOQ
    private final TransactionStatus transactionStatus;

    SpringTransaction(TransactionStatus transactionStatus) {
        this.transactionStatus = transactionStatus;
    }

    public TransactionStatus getTxStatus() {
        return this.transactionStatus;
    }
}

19 Source : TransactionCallbackWithoutResult.java
with MIT License
from Vip-Augus

@Override
@Nullable
public final Object doInTransaction(TransactionStatus status) {
    doInTransactionWithoutResult(status);
    return null;
}

19 Source : TestTransaction.java
with MIT License
from Vip-Augus

/**
 * Determine whether a test-managed transaction is currently <em>active</em>.
 * @return {@code true} if a test-managed transaction is currently active
 * @see #start()
 * @see #end()
 */
public static boolean isActive() {
    TransactionContext transactionContext = TransactionContextHolder.getCurrentTransactionContext();
    if (transactionContext != null) {
        TransactionStatus transactionStatus = transactionContext.getTransactionStatus();
        return (transactionStatus != null && !transactionStatus.isCompleted());
    }
    return false;
}

19 Source : TransactionUtil.java
with Apache License 2.0
from tiankong0310

/**
 * 开启新的只读事务
 */
public static TransactionStatus beginNewReadTransaction() {
    DefaultTransactionDefinition td = new DefaultTransactionDefinition(TransactionDefinition.PROPAGATION_REQUIRES_NEW);
    td.setReadOnly(true);
    TransactionStatus status = getTransactionManager().getTransaction(td);
    return status;
}

19 Source : TransactionUtil.java
with Apache License 2.0
from tiankong0310

/**
 * 提交事务
 */
public static void commit(TransactionStatus status) {
    getTransactionManager().commit(status);
}

19 Source : TransactionUtil.java
with Apache License 2.0
from tiankong0310

/**
 * 若没有事务则开启事务,有则使用当前事务。
 */
public static TransactionStatus beginTransaction() {
    DefaultTransactionDefinition td = new DefaultTransactionDefinition(TransactionDefinition.PROPAGATION_REQUIRED);
    TransactionStatus status = getTransactionManager().getTransaction(td);
    return status;
}

19 Source : TransactionUtil.java
with Apache License 2.0
from tiankong0310

/**
 * 开启新事务
 */
public static TransactionStatus beginNewTransaction() {
    DefaultTransactionDefinition td = new DefaultTransactionDefinition(TransactionDefinition.PROPAGATION_REQUIRES_NEW);
    TransactionStatus status = getTransactionManager().getTransaction(td);
    return status;
}

19 Source : TransactionUtil.java
with Apache License 2.0
from tiankong0310

/**
 * 回滚事务
 */
public static void rollback(TransactionStatus status) {
    if (!status.isCompleted()) {
        getTransactionManager().rollback(status);
    }
}

19 Source : PlatformTransactionManagerAdapter.java
with Apache License 2.0
from teiid

public void commit(TransactionStatus status) {
    this.platformTransactionManager.commit(status);
    TRANSACTION_HOLDERS.remove();
}

19 Source : PlatformTransactionManagerAdapter.java
with Apache License 2.0
from teiid

public void rollback(TransactionStatus status) {
    this.platformTransactionManager.rollback(status);
    TRANSACTION_HOLDERS.remove();
}

19 Source : StatefullTransactionalLoopService.java
with GNU Affero General Public License v3.0
from progilone

private TransactionStatus saveIfNeeded(final long nb, final long nbCommit, final TransactionStatus status, final boolean readonly) {
    if (nb % nbCommit == 0) {
        if (LOG.isTraceEnabled()) {
            LOG.trace("{} traités...", nb);
        }
        transactionService.commitTransaction(status);
        return transactionService.startTransaction(readonly);
    }
    return status;
}

19 Source : StatefullTransactionalLoopService.java
with GNU Affero General Public License v3.0
from progilone

public <T> void loop(final List<T> enreplacedies, final long nbCommit, final boolean readonly, final LoopCallback<T> c) {
    TransactionStatus status = transactionService.startTransaction(readonly);
    try {
        int nb = 0;
        for (final T e : enreplacedies) {
            c.doLoop(e);
            status = saveIfNeeded(++nb, nbCommit, status, readonly);
        }
        transactionService.commitTransaction(status);
    } catch (final RuntimeException e) {
        transactionService.rollbackTransaction(status);
        throw e;
    }
}

19 Source : TransactionManager.java
with MIT License
from PacktPublishing

@Override
public void commit(TransactionStatus status) throws TransactionException {
}

19 Source : TransactionManager.java
with MIT License
from PacktPublishing

@Override
public void rollback(TransactionStatus status) throws TransactionException {
}

19 Source : SpringTransaction.java
with Apache License 2.0
from micronaut-projects

/**
 * Adapts a Spring transaction for JOOQ.
 *
 * @author Lukas Eder
 * @author Andreas Ahlenstorf
 * @author Phillip Webb
 * @since 1.2.0
 */
@Internal
clreplaced SpringTransaction implements Transaction {

    // Based on the jOOQ-spring-example from https://github.com/jOOQ/jOOQ
    private final TransactionStatus transactionStatus;

    /**
     * Wrap existing Spring {@link TransactionStatus} object with jOOQ transaction.
     *
     * @param transactionStatus The transaction status object
     */
    SpringTransaction(TransactionStatus transactionStatus) {
        this.transactionStatus = transactionStatus;
    }

    /**
     * Get underlying Spring transaction status.
     *
     * @return The transaction status object
     */
    public TransactionStatus getTxStatus() {
        return this.transactionStatus;
    }
}

19 Source : TransactionCallbackWithoutResult.java
with Apache License 2.0
from langtianya

@Override
public final Object doInTransaction(TransactionStatus status) {
    doInTransactionWithoutResult(status);
    return null;
}

19 Source : TestTransaction.java
with Apache License 2.0
from langtianya

/**
 * Determine whether a test-managed transaction is currently <em>active</em>.
 * @return {@code true} if a test-managed transaction is currently active
 * @see #start()
 * @see #end()
 */
public static boolean isActive() {
    TransactionContext transactionContext = TransactionContextHolder.getCurrentTransactionContext();
    if (transactionContext != null) {
        TransactionStatus transactionStatus = transactionContext.getTransactionStatus();
        return (transactionStatus != null) && (!transactionStatus.isCompleted());
    }
    // else
    return false;
}

19 Source : AbstractPollingMessageListenerContainer.java
with Apache License 2.0
from langtianya

/**
 * Perform a rollback, handling rollback exceptions properly.
 * @param status object representing the transaction
 * @param ex the thrown listener exception or error
 */
private void rollbackOnException(TransactionStatus status, Throwable ex) {
    logger.debug("Initiating transaction rollback on listener exception", ex);
    try {
        this.transactionManager.rollback(status);
    } catch (RuntimeException ex2) {
        logger.error("Listener exception overridden by rollback exception", ex);
        throw ex2;
    } catch (Error err) {
        logger.error("Listener exception overridden by rollback error", ex);
        throw err;
    }
}

19 Source : TransactionInfo.java
with GNU General Public License v3.0
from kaixinzyw

public void setStatus(TransactionStatus status) {
    this.status = status;
}

19 Source : TransactionUtils.java
with GNU General Public License v3.0
from gxing19

/**
 * commit transactional
 *
 * @param transactionStatus
 */
public void commit(TransactionStatus transactionStatus) {
    dataSourceTransactionManager.commit(transactionStatus);
    logger.info("commit transactional");
}

19 Source : TransactionBean.java
with Apache License 2.0
from appjishu

public void setTs(TransactionStatus ts) {
    this.ts = ts;
}

19 Source : GeronimoPlatformTransactionManager.java
with Apache License 2.0
from apache

public void rollback(TransactionStatus status) throws TransactionException {
    platformTransactionManager.rollback(status);
}

18 Source : PlatformTransactionManagerFacade.java
with MIT License
from Vip-Augus

@Override
public void rollback(TransactionStatus status) {
    delegate.rollback(status);
}

18 Source : TransactionTemplate.java
with MIT License
from Vip-Augus

@Override
@Nullable
public <T> T execute(TransactionCallback<T> action) throws TransactionException {
    replacedert.state(this.transactionManager != null, "No PlatformTransactionManager set");
    if (this.transactionManager instanceof CallbackPreferringPlatformTransactionManager) {
        return ((CallbackPreferringPlatformTransactionManager) this.transactionManager).execute(this, action);
    } else {
        TransactionStatus status = this.transactionManager.getTransaction(this);
        T result;
        try {
            result = action.doInTransaction(status);
        } catch (RuntimeException | Error ex) {
            // Transactional code threw application exception -> rollback
            rollbackOnException(status, ex);
            throw ex;
        } catch (Throwable ex) {
            // Transactional code threw unexpected exception -> rollback
            rollbackOnException(status, ex);
            throw new UndeclaredThrowableException(ex, "TransactionCallback threw undeclared checked exception");
        }
        this.transactionManager.commit(status);
        return result;
    }
}

18 Source : TransactionAspectSupport.java
with MIT License
from Vip-Augus

/**
 * Prepare a TransactionInfo for the given attribute and status object.
 * @param txAttr the TransactionAttribute (may be {@code null})
 * @param joinpointIdentification the fully qualified method name
 * (used for monitoring and logging purposes)
 * @param status the TransactionStatus for the current transaction
 * @return the prepared TransactionInfo object
 */
protected TransactionInfo prepareTransactionInfo(@Nullable PlatformTransactionManager tm, @Nullable TransactionAttribute txAttr, String joinpointIdentification, @Nullable TransactionStatus status) {
    TransactionInfo txInfo = new TransactionInfo(tm, txAttr, joinpointIdentification);
    if (txAttr != null) {
        // We need a transaction for this method...
        if (logger.isTraceEnabled()) {
            logger.trace("Getting transaction for [" + txInfo.getJoinpointIdentification() + "]");
        }
        // The transaction manager will flag an error if an incompatible tx already exists.
        txInfo.newTransactionStatus(status);
    } else {
        // The TransactionInfo.hasTransaction() method will return false. We created it only
        // to preserve the integrity of the ThreadLocal stack maintained in this clreplaced.
        if (logger.isTraceEnabled()) {
            logger.trace("No need to create transaction for [" + joinpointIdentification + "]: This method is not transactional.");
        }
    }
    // We always bind the TransactionInfo to the thread, even if we didn't create
    // a new transaction here. This guarantees that the TransactionInfo stack
    // will be managed correctly even if no transaction was created by this aspect.
    txInfo.bindToThread();
    return txInfo;
}

18 Source : JmsTransactionManagerTests.java
with MIT License
from Vip-Augus

@Test
public void testLazyWithoutSessionAccess() {
    ConnectionFactory cf = mock(ConnectionFactory.clreplaced);
    JmsTransactionManager tm = new JmsTransactionManager(cf);
    tm.setLazyResourceRetrieval(true);
    TransactionStatus ts = tm.getTransaction(new DefaultTransactionDefinition());
    tm.commit(ts);
}

18 Source : DelegatingPlatformTransactionManager.java
with Apache License 2.0
from teiid

@Override
public void commit(TransactionStatus status) throws TransactionException {
    check();
    this.delegate.commit(status);
}

18 Source : DelegatingPlatformTransactionManager.java
with Apache License 2.0
from teiid

@Override
public void rollback(TransactionStatus status) throws TransactionException {
    check();
    this.delegate.rollback(status);
}

18 Source : SpringClient.java
with Apache License 2.0
from teiid

public clreplaced SpringClient extends LocalClient {

    private TeiidServer server;

    private TransactionStatus status;

    public SpringClient(String vdbName, String vdbVersion, Properties properties, TeiidServer server, Map<Object, Future<Boolean>> loading) {
        super(vdbName, vdbVersion, properties, loading);
        this.server = server;
    }

    @Override
    protected TeiidDriver getDriver() {
        return this.server.getDriver();
    }

    @Override
    public String startTransaction() throws SQLException {
        if (this.server.isUsingPlatformTransactionManager()) {
            status = this.server.getPlatformTransactionManagerAdapter().getOrCreateTransaction(true).status;
            return "anyid";
        }
        return super.startTransaction();
    }

    @Override
    public void commit(String txnId) throws SQLException {
        if (this.server.isUsingPlatformTransactionManager()) {
            this.server.getPlatformTransactionManagerAdapter().commit(status);
        } else {
            super.commit(txnId);
        }
    }

    @Override
    public void rollback(String txnId) throws SQLException {
        if (this.server.isUsingPlatformTransactionManager()) {
            this.server.getPlatformTransactionManagerAdapter().rollback(status);
        } else {
            super.rollback(txnId);
        }
    }
}

18 Source : DefaultTransactionService.java
with Apache License 2.0
from spot-next

@Override
public void rollbackToSavePoint(final TransactionStatus status, final Object savePoint) throws TransactionException {
    if (getCurrentTransaction().isPresent() && !getCurrentTransaction().get().isCompleted()) {
        getCurrentTransaction().get().rollbackToSavepoint(savePoint);
        currentTransaction.remove();
    } else {
        throw new UnexpectedRollbackException("There is no active transaction.");
    }
}

18 Source : DefaultTransactionService.java
with Apache License 2.0
from spot-next

@Override
public Object createSavePoint(final TransactionStatus status) throws TransactionException {
    if (status != null && !getCurrentTransaction().get().isCompleted()) {
        return getCurrentTransaction().get().createSavepoint();
    } else {
        throw new CannotCreateTransactionException("Cannot create savepoint as there is no active transaction.");
    }
}

18 Source : TransactionTemplate.java
with Apache License 2.0
from SourceHot

/**
 * 执行,做一个事务
 *
 * @param action the callback object that specifies the transactional action
 * @param <T>
 * @return
 * @throws TransactionException
 */
@Override
@Nullable
public <T> T execute(TransactionCallback<T> action) throws TransactionException {
    replacedert.state(this.transactionManager != null, "No PlatformTransactionManager set");
    // 事务管理是否是 xxx接口
    if (this.transactionManager instanceof CallbackPreferringPlatformTransactionManager) {
        // 强转执行
        return ((CallbackPreferringPlatformTransactionManager) this.transactionManager).execute(this, action);
    } else {
        // 获取事务状态
        TransactionStatus status = this.transactionManager.getTransaction(this);
        // 返回结果
        T result;
        try {
            // 事务回调执行
            result = action.doInTransaction(status);
        } catch (RuntimeException | Error ex) {
            // Transactional code threw application exception -> rollback
            // 回滚异常
            rollbackOnException(status, ex);
            throw ex;
        } catch (Throwable ex) {
            // Transactional code threw unexpected exception -> rollback
            // 回滚异常
            rollbackOnException(status, ex);
            throw new UndeclaredThrowableException(ex, "TransactionCallback threw undeclared checked exception");
        }
        // 提交
        this.transactionManager.commit(status);
        return result;
    }
}

18 Source : TransactionAspectSupport.java
with Apache License 2.0
from SourceHot

/**
 * Prepare a TransactionInfo for the given attribute and status object.
 *
 * @param txAttr                  the TransactionAttribute (may be {@code null})
 * @param joinpointIdentification the fully qualified method name (used for monitoring and
 *                                logging purposes)
 * @param status                  the TransactionStatus for the current transaction
 * @return the prepared TransactionInfo object
 */
protected TransactionInfo prepareTransactionInfo(@Nullable PlatformTransactionManager tm, @Nullable TransactionAttribute txAttr, String joinpointIdentification, @Nullable TransactionStatus status) {
    // 初始化
    TransactionInfo txInfo = new TransactionInfo(tm, txAttr, joinpointIdentification);
    if (txAttr != null) {
        // We need a transaction for this method...
        if (logger.isTraceEnabled()) {
            logger.trace("Getting transaction for [" + txInfo.getJoinpointIdentification() + "]");
        }
        // The transaction manager will flag an error if an incompatible tx already exists.
        txInfo.newTransactionStatus(status);
    } else {
        // The TransactionInfo.hasTransaction() method will return false. We created it only
        // to preserve the integrity of the ThreadLocal stack maintained in this clreplaced.
        if (logger.isTraceEnabled()) {
            logger.trace("No need to create transaction for [" + joinpointIdentification + "]: This method is not transactional.");
        }
    }
    // We always bind the TransactionInfo to the thread, even if we didn't create
    // a new transaction here. This guarantees that the TransactionInfo stack
    // will be managed correctly even if no transaction was created by this aspect.
    // 和线程绑定
    txInfo.bindToThread();
    return txInfo;
}

18 Source : TransactionService.java
with GNU Affero General Public License v3.0
from progilone

public void rollbackTransaction(final TransactionStatus status) {
    if (!status.isCompleted()) {
        txManager.rollback(status);
    }
}

18 Source : Transaction.java
with GNU General Public License v3.0
from MoeraOrg

private static void rollbackTransaction(PlatformTransactionManager txManager, TransactionStatus status) {
    if (status != null) {
        txManager.rollback(status);
    }
}

18 Source : Transaction.java
with GNU General Public License v3.0
from MoeraOrg

public static <T> T execute(PlatformTransactionManager txManager, Callable<T> inside) throws Throwable {
    TransactionStatus status = beginTransaction(txManager);
    T result;
    try {
        result = inside.call();
        commitTransaction(txManager, status);
    } catch (Throwable e) {
        rollbackTransaction(txManager, status);
        throw e;
    }
    return result;
}

18 Source : TransactionAspectSupport.java
with MIT License
from mindcarver

/**
 * Prepare a TransactionInfo for the given attribute and status object.
 * @param txAttr the TransactionAttribute (may be {@code null})
 * @param joinpointIdentification the fully qualified method name
 * (used for monitoring and logging purposes)
 * @param status the TransactionStatus for the current transaction
 * @return the prepared TransactionInfo object
 */
protected TransactionInfo prepareTransactionInfo(@Nullable PlatformTransactionManager tm, @Nullable TransactionAttribute txAttr, String joinpointIdentification, @Nullable TransactionStatus status) {
    TransactionInfo txInfo = new TransactionInfo(tm, txAttr, joinpointIdentification);
    if (txAttr != null) {
        // We need a transaction for this method...
        if (logger.isTraceEnabled()) {
            logger.trace("Getting transaction for [" + txInfo.getJoinpointIdentification() + "]");
        }
        // The transaction manager will flag an error if an incompatible tx already exists.
        txInfo.newTransactionStatus(status);
    } else {
        // The TransactionInfo.hasTransaction() method will return false. We created it only
        // to preserve the integrity of the ThreadLocal stack maintained in this clreplaced.
        if (logger.isTraceEnabled()) {
            logger.trace("Don't need to create transaction for [" + joinpointIdentification + "]: This method isn't transactional.");
        }
    }
    // We always bind the TransactionInfo to the thread, even if we didn't create
    // a new transaction here. This guarantees that the TransactionInfo stack
    // will be managed correctly even if no transaction was created by this aspect.
    txInfo.bindToThread();
    return txInfo;
}

18 Source : TransactionTemplate.java
with Apache License 2.0
from langtianya

@Override
public <T> T execute(TransactionCallback<T> action) throws TransactionException {
    if (this.transactionManager instanceof CallbackPreferringPlatformTransactionManager) {
        return ((CallbackPreferringPlatformTransactionManager) this.transactionManager).execute(this, action);
    } else {
        TransactionStatus status = this.transactionManager.getTransaction(this);
        T result;
        try {
            result = action.doInTransaction(status);
        } catch (RuntimeException ex) {
            // Transactional code threw application exception -> rollback
            rollbackOnException(status, ex);
            throw ex;
        } catch (Error err) {
            // Transactional code threw error -> rollback
            rollbackOnException(status, err);
            throw err;
        } catch (Exception ex) {
            // Transactional code threw unexpected exception -> rollback
            rollbackOnException(status, ex);
            throw new UndeclaredThrowableException(ex, "TransactionCallback threw undeclared checked exception");
        }
        this.transactionManager.commit(status);
        return result;
    }
}

18 Source : TransactionAspectSupport.java
with Apache License 2.0
from langtianya

/**
 * Prepare a TransactionInfo for the given attribute and status object.
 * @param txAttr the TransactionAttribute (may be {@code null})
 * @param joinpointIdentification the fully qualified method name
 * (used for monitoring and logging purposes)
 * @param status the TransactionStatus for the current transaction
 * @return the prepared TransactionInfo object
 */
protected TransactionInfo prepareTransactionInfo(PlatformTransactionManager tm, TransactionAttribute txAttr, String joinpointIdentification, TransactionStatus status) {
    TransactionInfo txInfo = new TransactionInfo(tm, txAttr, joinpointIdentification);
    if (txAttr != null) {
        // We need a transaction for this method
        if (logger.isTraceEnabled()) {
            logger.trace("Getting transaction for [" + txInfo.getJoinpointIdentification() + "]");
        }
        // The transaction manager will flag an error if an incompatible tx already exists
        txInfo.newTransactionStatus(status);
    } else {
        // The TransactionInfo.hasTransaction() method will return
        // false. We created it only to preserve the integrity of
        // the ThreadLocal stack maintained in this clreplaced.
        if (logger.isTraceEnabled())
            logger.trace("Don't need to create transaction for [" + joinpointIdentification + "]: This method isn't transactional.");
    }
    // We always bind the TransactionInfo to the thread, even if we didn't create
    // a new transaction here. This guarantees that the TransactionInfo stack
    // will be managed correctly even if no transaction was created by this aspect.
    txInfo.bindToThread();
    return txInfo;
}

18 Source : TransactionInfo.java
with GNU General Public License v3.0
from kaixinzyw

/**
 * @author 张亚伟 https://github.com/kaixinzyw
 */
public clreplaced TransactionInfo {

    private DataSourceTransactionManager tran;

    private TransactionStatus status;

    public DataSourceTransactionManager getTran() {
        return tran;
    }

    public void setTran(DataSourceTransactionManager tran) {
        this.tran = tran;
    }

    public TransactionStatus getStatus() {
        return status;
    }

    public void setStatus(TransactionStatus status) {
        this.status = status;
    }
}

18 Source : ADelegateTransactionManager.java
with GNU Lesser General Public License v3.0
from invesdwin

@Override
public void commit(final TransactionStatus status) {
    getDelegate().commit(status);
}

18 Source : ADelegateTransactionManager.java
with GNU Lesser General Public License v3.0
from invesdwin

@Override
public void rollback(final TransactionStatus status) {
    getDelegate().rollback(status);
}

18 Source : SpringHibernateTransaction.java
with Apache License 2.0
from illyasviel

/**
 * Spring Hibernate Transaction.
 * @author olOwOlo
 */
public clreplaced SpringHibernateTransaction extends HibernateTransaction {

    private final Session session;

    private final TransactionStatus txStatus;

    private final PlatformTransactionManager txManager;

    /**
     * Constructor.
     *
     * @param session Hibernate session
     * @param txManager Spring PlatformTransactionManager
     * @param txStatus Spring Transaction status
     * @param isScrollEnabled Whether or not scrolling is enabled
     * @param scrollMode Scroll mode to use if scrolling enabled
     */
    protected SpringHibernateTransaction(Session session, PlatformTransactionManager txManager, TransactionStatus txStatus, boolean isScrollEnabled, ScrollMode scrollMode) {
        super(session, isScrollEnabled, scrollMode);
        this.session = session;
        this.txManager = txManager;
        this.txStatus = txStatus;
    }

    @Override
    public void flush(RequestScope requestScope) {
        try {
            super.flush(requestScope);
        } catch (TransactionException e) {
            PersistenceException pe = (PersistenceException) e.getCause();
            if (pe.getCause() instanceof ConstraintViolationException) {
                throw new UnprocessableEnreplacedyException("Some fields violate constraint(notnull, unique, ...)", e);
            } else {
                throw e;
            }
        }
    }

    @Override
    public void commit(RequestScope scope) {
        try {
            flush(scope);
            txManager.commit(txStatus);
        } catch (org.springframework.transaction.TransactionException e) {
            throw new TransactionException(e);
        }
    }

    @Override
    public void close() throws IOException {
        if (session.isOpen() && !txStatus.isCompleted()) {
            txManager.rollback(txStatus);
            throw new IOException("Transaction not closed");
        }
    }
}

18 Source : TransactionUtils.java
with GNU General Public License v3.0
from gxing19

/**
 * rollback transactional
 *
 * @param transactionStatus
 */
public void rollback(TransactionStatus transactionStatus) {
    dataSourceTransactionManager.rollback(transactionStatus);
    logger.info("rollback transactional");
}

18 Source : TransactionManual.java
with GNU General Public License v3.0
from getrebuild

/**
 * 回滚
 *
 * @param status
 */
public static void rollback(TransactionStatus status) {
    getTxManager().rollback(status);
    status.flush();
}

18 Source : TransactionManual.java
with GNU General Public License v3.0
from getrebuild

/**
 * 提交
 *
 * @param status
 */
public static void commit(TransactionStatus status) {
    getTxManager().commit(status);
    status.flush();
}

18 Source : SpringHibernateTransaction.java
with MIT License
from FAForever

/**
 * Spring Hibernate Transaction.
 *
 * @author olOwOlo
 */
public clreplaced SpringHibernateTransaction extends HibernateTransaction {

    private final Session session;

    private final TransactionStatus txStatus;

    private final PlatformTransactionManager txManager;

    /**
     * Constructor.
     *
     * @param session Hibernate session
     * @param txManager Spring PlatformTransactionManager
     * @param txStatus Spring Transaction status
     * @param isScrollEnabled Whether or not scrolling is enabled
     * @param scrollMode Scroll mode to use if scrolling enabled
     */
    protected SpringHibernateTransaction(Session session, PlatformTransactionManager txManager, TransactionStatus txStatus, boolean isScrollEnabled, ScrollMode scrollMode) {
        super(session, isScrollEnabled, scrollMode);
        this.session = session;
        this.txManager = txManager;
        this.txStatus = txStatus;
    }

    @Override
    public void commit(RequestScope scope) {
        try {
            flush(scope);
            txManager.commit(txStatus);
        } catch (org.springframework.transaction.TransactionException e) {
            throw new TransactionException(e);
        }
    }

    @Override
    public void close() throws IOException {
        if (session.isOpen() && !txStatus.isCompleted()) {
            txManager.rollback(txStatus);
            throw new IOException("Transaction not closed");
        }
    }
}

18 Source : TransactionBean.java
with Apache License 2.0
from appjishu

/**
 * 事务实体类
 * @author  Dennie [email protected]
 * @date	 2018年11月16日 上午11:37:39
 * @version v1.0
 */
public clreplaced TransactionBean {

    private DataSourceTransactionManager dtm;

    private DefaultTransactionDefinition dtf;

    private TransactionStatus ts;

    /**
     * 提交事务
     */
    public void commit() {
        this.dtm.commit(this.ts);
    }

    /**
     * 回滚事务
     */
    public void rollback() {
        this.dtm.rollback(this.ts);
    }

    /**
     * 事务管理器
     * @return DataSourceTransactionManager
     */
    public DataSourceTransactionManager getDtm() {
        return dtm;
    }

    public void setDtm(DataSourceTransactionManager dtm) {
        this.dtm = dtm;
    }

    /**
     * 默认事务定义
     * @return DefaultTransactionDefinition
     */
    public DefaultTransactionDefinition getDtf() {
        return dtf;
    }

    public void setDtf(DefaultTransactionDefinition dtf) {
        this.dtf = dtf;
    }

    /**
     * 传输状态
     * @return TransactionStatus
     */
    public TransactionStatus getTs() {
        return ts;
    }

    public void setTs(TransactionStatus ts) {
        this.ts = ts;
    }
}

18 Source : GeronimoPlatformTransactionManager.java
with Apache License 2.0
from apache

public void commit(TransactionStatus status) throws TransactionException {
    platformTransactionManager.commit(status);
}

18 Source : PersistHelper.java
with Apache License 2.0
from alibaba

public <T> T tx(TransactionRun<T> run) {
    TransactionStatus txStatus = getTransactionStatus();
    T result;
    try {
        result = run.run();
    } catch (RuntimeException re) {
        transactionManager.rollback(txStatus);
        throw re;
    } catch (Error err) {
        transactionManager.rollback(txStatus);
        throw err;
    } catch (Exception e) {
        transactionManager.rollback(txStatus);
        throw new UndeclaredThrowableException(e, "undeclared error happened in transaction");
    }
    transactionManager.commit(txStatus);
    return result;
}

See More Examples