gpt4 book ai didi

java - 使用 JTATransactionManager 处理事务?

转载 作者:行者123 更新时间:2023-11-28 23:39:13 26 4
gpt4 key购买 nike

我在 Tomcat7 中使用 spring3 和 Hibernate4。

我必须使用 JTATransactionManager 并且我有以下配置。

<bean id="transactionManager"  
class="org.springframework.transaction.jta.JtaTransactionManager">
<property name="userTransactionName" value="java:comp/UserTransaction"></property>
</bean>

在上面的配置中,java:comp/UserTransaction 定义在哪里?

谢谢!

最佳答案

它是对容器提供的用户事务对象的 JNDI 引用。

它不是用户可配置的(因为您不能自己更改该值)。该值取决于您使用的 EE 容器。

至于用户交易对象到底是什么,参见Wikipedia :

UserTransaction interface

The javax.transaction.UserTransaction interface provides the application the ability to control transaction boundaries programmatically. This interface may be used by Java client programs or EJB beans.

The UserTransaction.begin() method starts a global transaction and associates the transaction with the calling thread. The transaction-to-thread association is managed transparently by the Transaction Manager.

Support for nested transactions is not required. The UserTransaction.begin method throws the NotSupportedException when the calling thread is already associated with a transaction and the transaction manager implementation does not support nested transactions.

Transaction context propagation between application programs is provided by the underlying transaction manager implementations on the client and server machines. The transaction context format used for propagation is protocol dependent and must be negotiated between the client and server hosts. For example, if the transaction manager is an implementation of the JTS specification, it will use the transaction context propagation format as specified in the CORBA OTS 1.1 specification. Transaction propagation is transparent to application programs..

关于java - 使用 JTATransactionManager 处理事务?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21621845/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com