Hibernate与JPA与JDO - 每个的优缺点? [英] Hibernate vs JPA vs JDO - pros and cons of each?

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

问题描述

我熟悉ORM作为一个概念,几年前我甚至使用nHibernate来开发.NET项目;然而,我还没有跟上Java的ORM主题,并没有机会使用这些工具。



但是,现在我可能有有机会开始为我们的应用程序使用一些ORM工具,试图摆脱一系列遗留的Web服务。



我很难时间讲述了JPA规范,Hibernate库本身和JDO提供的内容之间的区别。



所以,我明白这个问题有点儿开放式,但我希望得到一些意见:




  • 每个的优点和缺点是什么?

  • 你会为新项目建议哪一种?

  • 是否有某些条件适合使用一个框架与另一个框架?


解决方案

有些笔记:
$ b


  • JDO和JPA都是规范,不是实现。

  • 这个想法是你可以交换JPA i如果您限制您的代码仅使用标准JPA,则可以使用它。 (同上,JDO)。
  • Hibernate可以用作JPA的一个这样的实现。

  • 然而,Hibernate提供了一个本地API,并超出了JPA。



IMO,我会推荐Hibernate。 >

如果您需要使用Hibernate特有的功能,您应该做些什么意见/问题。有很多方法可以看到这一点,但我的建议是:如果您并不担心供应商的前景,那么我们的建议就是:绑定,然后在Hibernate和其他JPA和JDO实现之间做出选择包括决策制定中各个供应商特定的扩展。


  • 如果您担心供应商绑定的前景,并且您无法使用JPA而无需诉诸供应商特定的扩展,那么请不要使用JPA。 (对于JDO同上)。


    实际上,您可能需要权衡多少钱

  • / em>你担心供应商搭配与多少你需要这些供应商特定的扩展。



    还有其他因素,比如你/你的员工对各自技术的了解程度,产品的授权费用,以及你相信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与JPA与JDO - 每个的优缺点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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