JPA2 + Hibernate 3.6.0中的JTA或LOCAL事务? [英] JTA or LOCAL transactions in JPA2+Hibernate 3.6.0?

查看:147
本文介绍了JPA2 + Hibernate 3.6.0中的JTA或LOCAL事务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在重新思考我们的技术堆栈,下面是我们的选择(由于应用程序的复杂性等原因,我们不能没有Spring和Hibernate)。我们也从J2EE 1.4迁移到Java EE 5.

We are in the process of re-thinking our tech stack and below are our choices (We can't live without Spring and Hibernate due to the complexity etc of the app). We are also moving from J2EE 1.4 to Java EE 5.

技术堆栈


  1. Java EE 5

  2. JPA 2.0(我知道Java EE 5仅支持
    JPA 1.0,但我们希望使用Hibernate
    作为JPA提供者)

  3. Hibernate 3.6.0(我们已经拥有
    大量的hbm文件,其中包含自定义类型
    等等所以我们不希望将
    这些文件迁移到JPA这意味着
    我们希望两个jpa / hbm映射一起工作
    ,因此Hibernate为
    JPA提供者,而不是使用
    默认值为App
    Server )

现在的问题是我想坚持本地交易,但其他团队成员想要使用JTA。我已经使用J2EE工作了9年,我一次又一次地听到人们建议如果我不需要两个阶段提交就坚持本地交易。这不仅是出于性能原因,而且本地事务的调试/故障排除比JTA容易得多(即使JTA仅在需要时进行单阶段提交)。

Now the problems is that I want to stick with local transactions but other team members want to use JTA. I have been working with J2EE for last 9 years and I've heard time and again people suggesting to stick with local transactions if I doesn't need two phase commits. This is not only for performance reasons but debugging/troubleshooting a local transaction is lot easier than a JTA (even if JTA only does single phase commit when required).

我的建议是使用spring声明式事务管理+本地事务(HibernateTransactionManager)而不是容器JTA

我想确定我是偏执狂还是我有一个有效的观点。我想听听Java EE世界其他人的想法。或者请指出一篇合适的文章。

I want to make sure if I am being paranoid or I have a valid point. I'd like to hear what the rest of the Java EE world thinks. Or please point me an appropriate article.

推荐答案

JTA并不意味着两阶段提交。我认为这是JTA和XA驱动程序的组合,可以进行两阶段提交。

JTA doesn't mean two phase commits. I think it's the combination of JTA and XA drivers that makes two phase commits possible.

我仍然建议使用JTA和声明式事务而不是在代码中嵌入事务逻辑。交易最好以面向方面的方式完成,即春天。

I'd still recommend using JTA and declarative transactions over embedding transaction logic in code. Transactions are best done in aspect oriented fashion, a la Spring.

更新:

附加信息我发布了,我同意你的观点。我建议使用Spring声明式事务和 HibernateTransactionManager 类。

With the additional information you've posted, I agree with your argument. I'd recommend using Spring declarative transactions and the HibernateTransactionManager class.

这篇关于JPA2 + Hibernate 3.6.0中的JTA或LOCAL事务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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