JPA实现 - 哪一个最适合使用? [英] JPA Implementations - Which one is the best to use?

查看:86
本文介绍了JPA实现 - 哪一个最适合使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用了以下JPA实现:


  1. Hibernate,


  2. OpenJPA

每个人都有自己的长处和短处。我发现Hibernate是三者中最先进的,只是它将自己的一些增强功能与JPA混合在一起,这使得难以转向其他提供者。最重要的是,它的查询解析器在解释JPA时要宽松得多。他们让获得正确的库支持hibernate有点困难,因为我发现它试图获得所有依赖关系的正确版本。



Toplink没问题,只有一个有没有觉得它有点跛脚,因为它似乎甲骨文希望你使用/购买?他们更高级的图书馆。试图下载它也是一项任务,因为你需要通过运行jar文件来安装它。我发现它只实现了基本的JPA规范。我使用它的原因是hibernate使用了很多常用于其他开源项目的库,这些库经常会遇到classloarder问题,特别是在使用JBoss时。


$ b OpenJPA - 这是迄今为止最好的文档,很容易下载和使用,但它看起来很麻烦。也许它只是我的代码,但代码我发现更高级的用法,如与CascadeType.all设置OneToMany关系似乎没有工作。诚然,这可能是我的代码错了,我没有时间去测试一个干净的案例,但是很多这样的事件让我害怕使用它。我真的希望它变得更好。它的错误信息通常无助于解决问题。



还有哪些其他图书馆有人使用过,哪些是他们喜欢的?为什么?

解决方案

我对这些实现有相同的结论。
$ b


  1. OpenJPA看上去很麻烦


  2. Hibernate拥有大量的库,并且似乎遇到了延迟加载所有内容的问题。

    >

  3. Toplink成为我的选择。它不像Hibernate那样灵活,但它可以工作,而且我不需要安装 commons-logging

接下来我会尝试的是JPOX,它最近更名为 datanucleus 。 p>

I have made use of the following JPA implementations:

  1. Hibernate,
  2. Toplink,
  3. OpenJPA

Each of them has their own strengths and weaknesses. I found Hibernate the most advanced of the three except that it mixed some of its own enhancements with JPA which made it difficult to switch out to other providers. Most importantly, its query parser was much more lenient when interpreting JPA. They make it slightly difficult to get the correct libraries to support hibernate because I found it a mission trying to get the right versions of all the dependencies.

Toplink was ok but one is left with the feeling that it is slightly crippled as it seems Oracle wants you to use/buy? their more advanced library. Trying to download it was also a mission because you need to install it via running a jar file. I found that it implemented only the base JPA spec. The reason I used it was hibernate uses a lot of libraries that are commonly used in other open source projects that one would often get classloarder problems, especially when using JBoss

OpenJPA - This has by far the best documentation and is easy to download and use but it seems its very buggy. Maybe its just my code but code I found more advanced usage such as OneToMany relationships with CascadeType.all set just didn't seem to work. Admittedly It may be my code that was wrong and I haven't had time to test a clean case but many incidents like this leave me scared to use it. I really hope it gets better. Its error messages are often useless in helping solve the problem.

What other libraries have people used and which ones do they prefer and why?

解决方案

I had the same conclusions about these implementations.

  1. OpenJPA was/seemed buggy

  2. Hibernate had tons of libraries and seemed to have trouble with not lazy loading everything.

  3. Toplink ended up as my choice. It was not as flexible as Hibernate would have been but it works and I don't have to install commons-logging.

The one I would try next is JPOX, which has recently been renamed to datanucleus.

这篇关于JPA实现 - 哪一个最适合使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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