gpt4 book ai didi

java - 如何在 Tomcat 6 中为 Hibernate 使用 JTA 支持?

转载 作者:IT老高 更新时间:2023-10-28 20:39:48 25 4
gpt4 key购买 nike

他们建议在 Java EE 环境中使用 JTA 事务支持。

但是如何在Tomcat6中配置JTA让Hibernate Session可以使用呢?

Starting with version 3.0.1, Hibernate added the SessionFactory.getCurrentSession() method. Initially, this assumed usage of JTA transactions, where the JTA transaction defined both the scope and context of a current session. Given the maturity of the numerous stand-alone JTA TransactionManager implementations, most, if not all, applications should be using JTA transaction management, whether or not they are deployed into a J2EE container. Based on that, the JTA-based contextual sessions are all you need to use.

(Hibernate Reference Documentation | Architecture. Contextual Sessions)

最佳答案

如果您希望在 Tomcat 中支持 JTA,您需要使用独立的事务管理器,例如 Atomikos , JOTM , Bitronix , SimpleJTA , JBossTSGeronimoTM/Jencks .但老实说,如果您不打算处理跨多个资源的事务,那么您可以不使用 JTA(如果您真的需要 JTA,请使用完整的应用程序服务器)。

关于java - 如何在 Tomcat 6 中为 Hibernate 使用 JTA 支持?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2552612/

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