本文整理汇总了Java中org.springframework.transaction.support.DefaultTransactionStatus.getTransaction方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultTransactionStatus.getTransaction方法的具体用法?Java DefaultTransactionStatus.getTransaction怎么用?Java DefaultTransactionStatus.getTransaction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.transaction.support.DefaultTransactionStatus
的用法示例。
在下文中一共展示了DefaultTransactionStatus.getTransaction方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doRollback
import org.springframework.transaction.support.DefaultTransactionStatus; //导入方法依赖的package包/类
@Override
protected void doRollback(DefaultTransactionStatus status) {
JpaTransactionObject txObject = (JpaTransactionObject) status.getTransaction();
if (status.isDebug()) {
logger.debug("Rolling back JPA transaction on EntityManager [" +
txObject.getEntityManagerHolder().getEntityManager() + "]");
}
try {
EntityTransaction tx = txObject.getEntityManagerHolder().getEntityManager().getTransaction();
if (tx.isActive()) {
tx.rollback();
}
}
catch (PersistenceException ex) {
throw new TransactionSystemException("Could not roll back JPA transaction", ex);
}
finally {
if (!txObject.isNewEntityManagerHolder()) {
// Clear all pending inserts/updates/deletes in the EntityManager.
// Necessary for pre-bound EntityManagers, to avoid inconsistent state.
txObject.getEntityManagerHolder().getEntityManager().clear();
}
}
}
示例2: doCommit
import org.springframework.transaction.support.DefaultTransactionStatus; //导入方法依赖的package包/类
@Override
protected void doCommit(DefaultTransactionStatus status) {
JdoTransactionObject txObject = (JdoTransactionObject) status.getTransaction();
if (status.isDebug()) {
logger.debug("Committing JDO transaction on PersistenceManager [" +
txObject.getPersistenceManagerHolder().getPersistenceManager() + "]");
}
try {
Transaction tx = txObject.getPersistenceManagerHolder().getPersistenceManager().currentTransaction();
tx.commit();
}
catch (JDOException ex) {
// Assumably failed to flush changes to database.
throw convertJdoAccessException(ex);
}
}
示例3: doRollback
import org.springframework.transaction.support.DefaultTransactionStatus; //导入方法依赖的package包/类
@Override
protected void doRollback(DefaultTransactionStatus status) {
JdoTransactionObject txObject = (JdoTransactionObject) status.getTransaction();
if (status.isDebug()) {
logger.debug("Rolling back JDO transaction on PersistenceManager [" +
txObject.getPersistenceManagerHolder().getPersistenceManager() + "]");
}
try {
Transaction tx = txObject.getPersistenceManagerHolder().getPersistenceManager().currentTransaction();
if (tx.isActive()) {
tx.rollback();
}
}
catch (JDOException ex) {
throw new TransactionSystemException("Could not roll back JDO transaction", ex);
}
}
示例4: prepareForCommit
import org.springframework.transaction.support.DefaultTransactionStatus; //导入方法依赖的package包/类
@Override
protected void prepareForCommit(DefaultTransactionStatus status) {
if (this.earlyFlushBeforeCommit && status.isNewTransaction()) {
HibernateTransactionObject txObject = (HibernateTransactionObject) status.getTransaction();
Session session = txObject.getSessionHolder().getSession();
if (!session.getFlushMode().lessThan(FlushMode.COMMIT)) {
logger.debug("Performing an early flush for Hibernate transaction");
try {
session.flush();
}
catch (HibernateException ex) {
throw convertHibernateAccessException(ex);
}
finally {
session.setFlushMode(FlushMode.MANUAL);
}
}
}
}
示例5: doCommit
import org.springframework.transaction.support.DefaultTransactionStatus; //导入方法依赖的package包/类
@Override
protected void doCommit(DefaultTransactionStatus status) {
DataSourceTransactionObject txObject = (DataSourceTransactionObject) status.getTransaction();
Connection con = txObject.getConnectionHolder().getConnection();
if (status.isDebug()) {
logger.debug("Committing JDBC transaction on Connection [" + con + "]");
}
try {
con.commit();
}
catch (SQLException ex) {
throw new TransactionSystemException("Could not commit JDBC transaction", ex);
}
/**modify by guosg 这里提交ldtm事务*/
SynchronizationManager.getCurrentUserTransation().commit();
}
示例6: doRollback
import org.springframework.transaction.support.DefaultTransactionStatus; //导入方法依赖的package包/类
@Override
protected void doRollback(DefaultTransactionStatus status) {
DataSourceTransactionObject txObject = (DataSourceTransactionObject) status.getTransaction();
Connection con = txObject.getConnectionHolder().getConnection();
if (status.isDebug()) {
logger.debug("Rolling back JDBC transaction on Connection [" + con + "]");
}
try {
con.rollback();
}
catch (SQLException ex) {
throw new TransactionSystemException("Could not roll back JDBC transaction", ex);
}
/**modify by guosg 这里提交回滚事务*/
SynchronizationManager.getCurrentUserTransation().rollback();
}
示例7: doCommit
import org.springframework.transaction.support.DefaultTransactionStatus; //导入方法依赖的package包/类
@Override
protected void doCommit(final DefaultTransactionStatus status) {
final FcrepoTransactionObject tx = (FcrepoTransactionObject)status.getTransaction();
final InputStream is = null;
final String contentType = null;
try {
getClient().post(URI.create(baseUrl + "/" + tx.getSessionId() + COMMIT))
.body(is, contentType).perform();
} catch (final FcrepoOperationFailedException ex) {
LOGGER.debug("Transaction commit failed: ", ex);
throw new TransactionSystemException("Could not commit fcrepo transaction");
} finally {
tx.setSessionId(null);
}
}
示例8: doCommit
import org.springframework.transaction.support.DefaultTransactionStatus; //导入方法依赖的package包/类
@Override
protected void doCommit(DefaultTransactionStatus status) {
JcrTransactionObject txObject = (JcrTransactionObject) status
.getTransaction();
if (status.isDebug()) {
LOG.debug("Committing JCR transaction on session ["
+ txObject.getSessionHolder().getSession() + "]");
}
try {
txObject.getSessionHolder().getTransaction().commit();
} catch (Exception ex) {
// assumably from commit call to the underlying JCR repository
throw new TransactionSystemException(
"Could not commit JCR transaction", ex);
}
}
示例9: doRollback
import org.springframework.transaction.support.DefaultTransactionStatus; //导入方法依赖的package包/类
@Override
protected void doRollback(DefaultTransactionStatus status) {
JcrTransactionObject txObject = (JcrTransactionObject) status
.getTransaction();
if (status.isDebug()) {
LOG.debug("Rolling back JCR transaction on session ["
+ txObject.getSessionHolder().getSession() + "]");
}
try {
txObject.getSessionHolder().getTransaction().rollback();
} catch (Exception ex) {
throw new TransactionSystemException(
"Could not roll back JCR transaction", ex);
} finally {
if (!txObject.isNewSessionHolder()) {
// Clear all pending inserts/updates/deletes in the Session.
// Necessary for pre-bound Sessions, to avoid inconsistent
// state.
try {
txObject.getSessionHolder().getSession().refresh(false);
} catch (RepositoryException e) {
// we already throw an exception (hold back this one).
}
}
}
}
示例10: doRollback
import org.springframework.transaction.support.DefaultTransactionStatus; //导入方法依赖的package包/类
@Override
protected void doRollback(DefaultTransactionStatus status)
{
MolgenisTransaction transaction = (MolgenisTransaction) status.getTransaction();
if (LOG.isDebugEnabled())
{
LOG.debug("Rollback transaction [{}]", transaction.getId());
}
DefaultTransactionStatus jpaTransactionStatus = new DefaultTransactionStatus(
transaction.getDataSourceTransaction(), status.isNewTransaction(), status.isNewSynchronization(),
status.isReadOnly(), status.isDebug(), status.getSuspendedResources());
if (!status.isReadOnly())
{
transactionListeners.forEach(j -> j.rollbackTransaction(transaction.getId()));
}
super.doRollback(jpaTransactionStatus);
}
示例11: doCommit
import org.springframework.transaction.support.DefaultTransactionStatus; //导入方法依赖的package包/类
@Override
protected void doCommit(DefaultTransactionStatus status) {
String prefix="";
if(logger.isDebugEnabled()) {
prefix += "[" + TransactionId.get().getCurrentId() + "]";
try {
Connection connection = ((JdbcTransactionObjectSupport)status.getTransaction()).getConnectionHolder().getConnection();
prefix += "[" + (null != connection ? connection : "") + "]";
} catch (Exception e) {}
}
logger.debug(prefix+"DataSource doCommit");
//将status持久化到jvm内存
if(null!=TransactionContextFactory.getInstance()&& TransactionSupport.isProxy()){
logger.debug(prefix+"DataSource doCommit before store");
Transaction transaction=TransactionContextFactory.getInstance().persistent(status);
if(transaction instanceof DBTransaction){
logger.debug(prefix+"DataSource doCommit in store");
DBTransaction dbT=(DBTransaction)transaction;
dbT.setDataSource(getDataSource());
dbT.setIsNewConnectionHolder(checkNewConnectionHolder(status.getTransaction()));
}
}else{//如果事务容器工厂类初始化失败,执行默认逻辑
logger.debug(prefix+"DataSource doCommit don't store");
super.doCommit(status);
super.doCleanupAfterCompletion(status.getTransaction());
}
}
开发者ID:zhangkewei,项目名称:dubbo-transaction,代码行数:28,代码来源:DubboTransactionDataSourceTransactonManager.java
示例12: doCommit
import org.springframework.transaction.support.DefaultTransactionStatus; //导入方法依赖的package包/类
@Override
protected void doCommit(DefaultTransactionStatus status) {
DataSourceTransactionObject txObject = (DataSourceTransactionObject) status.getTransaction();
Connection con = txObject.getConnectionHolder().getConnection();
if (status.isDebug()) {
logger.debug("Committing JDBC transaction on Connection [" + con + "]");
}
try {
con.commit();
}
catch (SQLException ex) {
throw new TransactionSystemException("Could not commit JDBC transaction", ex);
}
}
示例13: doRollback
import org.springframework.transaction.support.DefaultTransactionStatus; //导入方法依赖的package包/类
@Override
protected void doRollback(DefaultTransactionStatus status) {
DataSourceTransactionObject txObject = (DataSourceTransactionObject) status.getTransaction();
Connection con = txObject.getConnectionHolder().getConnection();
if (status.isDebug()) {
logger.debug("Rolling back JDBC transaction on Connection [" + con + "]");
}
try {
con.rollback();
}
catch (SQLException ex) {
throw new TransactionSystemException("Could not roll back JDBC transaction", ex);
}
}
示例14: doSetRollbackOnly
import org.springframework.transaction.support.DefaultTransactionStatus; //导入方法依赖的package包/类
@Override
protected void doSetRollbackOnly(DefaultTransactionStatus status) {
DataSourceTransactionObject txObject = (DataSourceTransactionObject) status.getTransaction();
if (status.isDebug()) {
logger.debug("Setting JDBC transaction [" + txObject.getConnectionHolder().getConnection() +
"] rollback-only");
}
txObject.setRollbackOnly();
}
示例15: doSetRollbackOnly
import org.springframework.transaction.support.DefaultTransactionStatus; //导入方法依赖的package包/类
@Override
protected void doSetRollbackOnly(DefaultTransactionStatus status) {
CciLocalTransactionObject txObject = (CciLocalTransactionObject) status.getTransaction();
if (status.isDebug()) {
logger.debug("Setting CCI local transaction [" + txObject.getConnectionHolder().getConnection() +
"] rollback-only");
}
txObject.getConnectionHolder().setRollbackOnly();
}