java - 使用 JTATransactionManager 处理事务?

标签 java spring hibernate tomcat jta

我在 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/

相关文章:

java - 如何使用 JAVA 在 Selenium WebDriver 中打开 Chrome 开发者控制台

java - Hibernate 未在内存数据库中使用 H2 创建表

mysql - 用于获取表列数的 hibernate 查询

java - 服务发现模式

java - AlertDialog.Builder show(),在单击处理程序中崩溃

java - 如何使用 spring boot 和 jpa 在数据库中上传和保存文件?

java - 无法使用请求的结果类型为具有多个返回的查询创建 TypedQuery

java - 如何过滤 LocalContainerEntityManagerFactoryBean 扫描的实体?

java - Spring hibernate : org. hibernate.exception.SQLGrammarException

java - 从数据库中检索时对 hibernate 集合进行排序