• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java NestedTransactionNotSupportedException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.springframework.transaction.NestedTransactionNotSupportedException的典型用法代码示例。如果您正苦于以下问题:Java NestedTransactionNotSupportedException类的具体用法?Java NestedTransactionNotSupportedException怎么用?Java NestedTransactionNotSupportedException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



NestedTransactionNotSupportedException类属于org.springframework.transaction包,在下文中一共展示了NestedTransactionNotSupportedException类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: propagationNestedFailsInCaseOfExistingTransaction

import org.springframework.transaction.NestedTransactionNotSupportedException; //导入依赖的package包/类
@Test
public void propagationNestedFailsInCaseOfExistingTransaction() {
	MockUOWManager manager = new MockUOWManager();
	manager.setUOWStatus(UOWManager.UOW_STATUS_ACTIVE);
	WebSphereUowTransactionManager ptm = new WebSphereUowTransactionManager(manager);
	DefaultTransactionDefinition definition = new DefaultTransactionDefinition();
	definition.setPropagationBehavior(TransactionDefinition.PROPAGATION_NESTED);

	try {
		ptm.execute(definition, new TransactionCallback<String>() {
			@Override
			public String doInTransaction(TransactionStatus status) {
				return "result";
			}
		});
		fail("Should have thrown NestedTransactionNotSupportedException");
	}
	catch (NestedTransactionNotSupportedException ex) {
		// expected
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:22,代码来源:WebSphereUowTransactionManagerTests.java


示例2: testPropagationNestedFailsInCaseOfExistingTransaction

import org.springframework.transaction.NestedTransactionNotSupportedException; //导入依赖的package包/类
public void testPropagationNestedFailsInCaseOfExistingTransaction() {
	MockUOWManager manager = new MockUOWManager();
	manager.setUOWStatus(UOWManager.UOW_STATUS_ACTIVE);
	WebSphereUowTransactionManager ptm = new WebSphereUowTransactionManager(manager);
	DefaultTransactionDefinition definition = new DefaultTransactionDefinition();
	definition.setPropagationBehavior(TransactionDefinition.PROPAGATION_NESTED);

	try {
		ptm.execute(definition, new TransactionCallback() {
			@Override
			public Object doInTransaction(TransactionStatus status) {
				return "result";
			}
		});
		fail("Should have thrown NestedTransactionNotSupportedException");
	}
	catch (NestedTransactionNotSupportedException ex) {
		// expected
	}
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:21,代码来源:WebSphereUowTransactionManagerTests.java


示例3: getSavepointManager

import org.springframework.transaction.NestedTransactionNotSupportedException; //导入依赖的package包/类
/**
 * This implementation exposes the SavepointManager interface
 * of the underlying transaction object, if any.
 */
@Override
protected SavepointManager getSavepointManager() {
	if (!isTransactionSavepointManager()) {
		throw new NestedTransactionNotSupportedException(
			"Transaction object [" + getTransaction() + "] does not support savepoints");
	}
	return (SavepointManager) getTransaction();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:13,代码来源:DefaultTransactionStatus.java


示例4: getConnectionHolderForSavepoint

import org.springframework.transaction.NestedTransactionNotSupportedException; //导入依赖的package包/类
protected ConnectionHolder getConnectionHolderForSavepoint() throws TransactionException {
	if (!isSavepointAllowed()) {
		throw new NestedTransactionNotSupportedException(
				"Transaction manager does not allow nested transactions");
	}
	if (!hasConnectionHolder()) {
		throw new TransactionUsageException(
				"Cannot create nested transaction if not exposing a JDBC transaction");
	}
	return getConnectionHolder();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:12,代码来源:JdbcTransactionObjectSupport.java


示例5: getSavepointManager

import org.springframework.transaction.NestedTransactionNotSupportedException; //导入依赖的package包/类
private SavepointManager getSavepointManager() {
	if (!isSavepointAllowed()) {
		throw new NestedTransactionNotSupportedException(
				"Transaction manager does not allow nested transactions");
	}
	SavepointManager savepointManager = getEntityManagerHolder().getSavepointManager();
	if (savepointManager == null) {
		throw new NestedTransactionNotSupportedException(
				"JpaDialect does not support savepoints - check your JPA provider's capabilities");
	}
	return savepointManager;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:13,代码来源:JpaTransactionManager.java


示例6: createSavepoint

import org.springframework.transaction.NestedTransactionNotSupportedException; //导入依赖的package包/类
/**
 * This implementation creates a JDBC 3.0 Savepoint and returns it.
 * @see java.sql.Connection#setSavepoint
 */
@Override
public Object createSavepoint() throws TransactionException {
	ConnectionHolder conHolder = getConnectionHolderForSavepoint();
	try {
		if (!conHolder.supportsSavepoints()) {
			throw new NestedTransactionNotSupportedException(
					"Cannot create a nested transaction because savepoints are not supported by your JDBC driver");
		}
		return conHolder.createSavepoint();
	}
	catch (SQLException ex) {
		throw new CannotCreateTransactionException("Could not create JDBC savepoint", ex);
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:19,代码来源:JdbcTransactionObjectSupport.java


示例7: doBegin

import org.springframework.transaction.NestedTransactionNotSupportedException; //导入依赖的package包/类
@Override
protected void doBegin(Object transaction, TransactionDefinition definition) throws TransactionException {
    JiniTransactionObject txObject = (JiniTransactionObject) transaction;
    if (logger.isTraceEnabled())
        logger.trace(logMessage("Beginning transaction [" + txObject + "]"));
    try {
        doJiniBegin(txObject, definition);
    } catch (UnsupportedOperationException ex) {
        // assume nested transaction not supported
        throw new NestedTransactionNotSupportedException("Implementation does not ex nested transactions", ex);
    }
}
 
开发者ID:Gigaspaces,项目名称:xap-openspaces,代码行数:13,代码来源:AbstractJiniTransactionManager.java


示例8: createSavepoint

import org.springframework.transaction.NestedTransactionNotSupportedException; //导入依赖的package包/类
public Object createSavepoint() throws TransactionException {
	this.savepointCounter++;
	String savepointName = ConnectionHolder.SAVEPOINT_NAME_PREFIX + this.savepointCounter;
	try {
		Savepoint sp=this.entityManager.setSavepoint(savepointName);
		return sp;
	} catch (SavepointNotSupportedException e) {
		throw new NestedTransactionNotSupportedException("Cannot create a nested transaction because savepoints are not supported.");
	} catch (Throwable ex) {
		throw new CannotCreateTransactionException("Could not create JDBC savepoint", ex);
	}
}
 
开发者ID:GeeQuery,项目名称:ef-orm,代码行数:13,代码来源:JefJpaDialect.java


示例9: getHazelcastTransactionContext

import org.springframework.transaction.NestedTransactionNotSupportedException; //导入依赖的package包/类
/**
 * Returns the transaction context holder bound to the current transaction. If
 * one cannot be found and a transaction is active, a new one will be created
 * and bound to the thread. If one cannot be found and a transaction is not
 * active, this method returns null.
 *
 * @param hazelcastInstance the Hazelcast instance used to create begin a
 * transaction if needed
 *
 * @return the transaction context holder if a transaction is active, null
 * otherwise
 */
private static TransactionContext getHazelcastTransactionContext(
    HazelcastInstance hazelcastInstance,
    boolean synchedLocalTransactionAllowed) {

  HazelcastTransactionContextHolder conHolder =
      (HazelcastTransactionContextHolder) TransactionSynchronizationManager.
      getResource(hazelcastInstance);

  if (conHolder != null && (conHolder.hasTransactionContext() || conHolder.
      isSynchronizedWithTransaction())) {
    // We are already synchronized with the transaction which means
    // someone already requested a transactional resource or the transaction
    // is being managed at the top level by HazelcastTransactionManager.

    if (!conHolder.hasTransactionContext()) {
      // I think this means we are synchronized with the transaction but
      // we don't have a transactional context because the transaction was
      // suspended. I don't see how we can do this with Hazelcast because
      // it binds the transaction context to the thread and doesn't
      // supported nested transactions. Maybe I'm missing something.

      throw new NestedTransactionNotSupportedException("Trying to resume a "
          + "Hazelcast transaction? Can't do that.");
    }
  }
  else if (TransactionSynchronizationManager.isSynchronizationActive()
      && synchedLocalTransactionAllowed) {
    // No holder or no transaction context but we want to be
    // synchronized to the transaction.
    if (conHolder == null) {
      conHolder = new HazelcastTransactionContextHolder();
      TransactionSynchronizationManager.bindResource(hazelcastInstance,
          conHolder);
    }

    TransactionContext transactionContext = hazelcastInstance.
        newTransactionContext();
    transactionContext.beginTransaction();

    conHolder.setTransactionContext(transactionContext);
    conHolder.setSynchronizedWithTransaction(true);
    conHolder.setTransactionActive(true);
    TransactionSynchronizationManager.registerSynchronization(
        new HazelcastTransactionSynchronization(conHolder, hazelcastInstance));
  }

  return conHolder != null ? conHolder.getTransactionContext() : null;
}
 
开发者ID:mpilone,项目名称:hazelcastmq,代码行数:61,代码来源:HazelcastUtils.java


示例10: getSavepointManager

import org.springframework.transaction.NestedTransactionNotSupportedException; //导入依赖的package包/类
/**
 * Return a SavepointManager for the underlying transaction, if possible.
 * <p>Default implementation always throws a NestedTransactionNotSupportedException.
 * @throws org.springframework.transaction.NestedTransactionNotSupportedException
 * if the underlying transaction does not support savepoints
 */
protected SavepointManager getSavepointManager() {
	throw new NestedTransactionNotSupportedException("This transaction does not support savepoints");
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:AbstractTransactionStatus.java



注:本文中的org.springframework.transaction.NestedTransactionNotSupportedException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java AWTDrawVisitor类代码示例发布时间:2022-05-22
下一篇:
Java CustomerInfo类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap