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

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

问题描述

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



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


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


Hibernate Reference Documentation | Architecture。Contextual Sessions )如果你想在Tomcat中支持JTA,你需要使用一个独立的事务管理器,比如 JOTM Bitronix SimpleJTA JBossTS GeronimoTM / Jencks 。但说实话,如果你不打算处理跨多个资源的事务,那么你可以没有JTA的生活(如果你真的需要JTA,使用一个完整的应用服务器)。

They recommend using JTA transaction support in Java EE environment.

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

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)

解决方案

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).

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

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