Hibernate vs JPA vs JDO - 各自的优缺点? [英] Hibernate vs JPA vs JDO - pros and cons of each?

查看:33
本文介绍了Hibernate vs JPA vs JDO - 各自的优缺点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我熟悉 ORM 作为一个概念,几年前我什至在一个 .NET 项目中使用过 nHibernate;然而,我没有跟上 Java 中 ORM 的话题,也没有机会使用任何这些工具.

但是,现在我可能有机会开始为我们的一个应用程序使用一些 ORM 工具,以尝试摆脱一系列遗留网络服务.

我很难说出 JPA 规范、Hibernate 库本身提供的内容以及 JDO 提供的内容之间的区别.

所以,我知道这个问题有点开放,但我希望得到一些意见:

  • 每种方法的优缺点是什么?
  • 您对新项目有什么建议?
  • 在某些情况下,使用一种框架与另一种框架是否有意义?

解决方案

一些注意事项:

  • JDO 和 JPA 都是规范,而不是实现.
  • 这个想法是,如果您将代码限制为仅使用标准 JPA,您可以交换 JPA 实现.(JDO 同上.)
  • Hibernate 可用作 JPA 的一种此类实现.
  • 但是,Hibernate 提供了一个原生 API,其功能超出了 JPA.

IMO,我会推荐 Hibernate.

<小时>

如果您需要使用 Hibernate 特定的功能,您应该怎么做,已经有一些评论/问题.有很多方法可以看待这个问题,但我的建议是:

  • 如果您不担心供应商搭售的前景,那么请在 Hibernate 和其他 JPA 和 JDO 实现之间做出选择包括在您的决策中的各种特定于供应商的扩展.

  • 如果您担心供应商搭售的前景,并且在不求助于供应商特定扩展的情况下无法使用 JPA,那么请不要使用 JPA.(JDO 同上).

实际上,您可能需要权衡您对供应商搭售的担忧程度与您需要这些供应商特定扩展的程度.>

还有其他因素,例如您/您的员工对各自技术的了解程度、产品的许可费用是多少,以及您相信谁的故事关于 JDO 和 JPA 未来会发生什么.

I'm familiar with ORM as a concept, and I've even used nHibernate several years ago for a .NET project; however, I haven't kept up with the topic of ORM in Java and haven't had a chance to use any of these tools.

But, now I may have the chance to begin to use some ORM tools for one of our applications, in an attempt to move away from a series of legacy web services.

I'm having a hard time telling the difference betweeen the JPA spec, what you get with the Hibernate library itself, and what JDO has to offer.

So, I understand that this question is a bit open-ended, but I was hoping to get some opinions on:

  • What are the pros and cons of each?
  • Which would you suggest for a new project?
  • Are there certain conditions when it would make sense to use one framework vs the other?

解决方案

Some notes:

  • JDO and JPA are both specifications, not implementations.
  • The idea is you can swap JPA implementations, if you restrict your code to use standard JPA only. (Ditto for JDO.)
  • Hibernate can be used as one such implementation of JPA.
  • However, Hibernate provides a native API, with features above and beyond that of JPA.

IMO, I would recommend Hibernate.


There have been some comments / questions about what you should do if you need to use Hibernate-specific features. There are many ways to look at this, but my advice would be:

  • If you are not worried by the prospect of vendor tie-in, then make your choice between Hibernate, and other JPA and JDO implementations including the various vendor specific extensions in your decision making.

  • If you are worried by the prospect of vendor tie-in, and you can't use JPA without resorting to vendor specific extensions, then don't use JPA. (Ditto for JDO).

In reality, you will probably need to trade-off how much you are worried by vendor tie-in versus how much you need those vendor specific extensions.

And there are other factors too, like how well you / your staff know the respective technologies, how much the products will cost in licensing, and whose story you believe about what is going to happen in the future for JDO and JPA.

这篇关于Hibernate vs JPA vs JDO - 各自的优缺点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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