如何在 Hibernate 的 Tomcat 6 中使用 JTA 支持? [英] How to use JTA support in Tomcat 6 for Hibernate?

查看:21
本文介绍了如何在 Hibernate 的 Tomcat 6 中使用 JTA 支持?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

They recommend using JTA transaction support in Java EE environment.

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

But how to configure JTA in Tomcat6 so that Hibernate Session could use it ?

从 3.0.1 版开始,Hibernate 添加了 SessionFactory.getCurrentSession() 方法.最初,这假定使用 JTA 事务,其中 JTA 事务定义了当前会话的范围和上下文.鉴于众多独立 JTA TransactionManager 实现的成熟度,大多数(如果不是全部)应用程序都应该使用 JTA 事务管理,无论它们是否部署到 J2EE 容器中.基于此,您只需要使用基于 JTA 的上下文会话.

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 参考文档 | 架构.上下文会话)

推荐答案

如果你想在 Tomcat 中支持 JTA,你需要使用一个独立的事务管理器,比如 AtomikosJOTMBitronixSimpleJTAJBossTSGeronimoTM/Jencks.但老实说,如果您不打算跨多个资源处理事务,那么您可以不用 JTA(如果您真的需要 JTA,请使用成熟的应用服务器).

If you want JTA support in Tomcat you'll need to use a standalone transaction manager like Atomikos, JOTM, Bitronix, SimpleJTA, JBossTS or GeronimoTM/Jencks. But honestly, if you're not going to handle transactions across multiple resources, then you can live without JTA (and if you really need JTA, use a full blown application server).

这篇关于如何在 Hibernate 的 Tomcat 6 中使用 JTA 支持?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆