Java JPA 实现 - 哪个最好用?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/576659/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
JPA Implementations - Which one is the best to use?
提问by mxc
I have made use of the following JPA implementations:
我使用了以下 JPA 实现:
- Hibernate,
- Toplink,
- OpenJPA
- 休眠,
- 顶联,
- 开放式JPA
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.
他们每个人都有自己的长处和短处。我发现 Hibernate 是三者中最先进的,除了它将自己的一些增强功能与 JPA 混合在一起,这使得很难切换到其他提供者。最重要的是,它的查询解析器在解释 JPA 时要宽松得多。它们使得获得正确的库来支持 hibernate 变得有些困难,因为我发现这是一项尝试获得所有依赖项的正确版本的任务。
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
Toplink 还可以,但有人觉得它有点残缺,因为 Oracle 似乎希望您使用/购买?他们更先进的图书馆。尝试下载它也是一项任务,因为您需要通过运行 jar 文件来安装它。我发现它只实现了基本的 JPA 规范。我使用它的原因是 hibernate 使用了很多在其他开源项目中常用的库,人们经常会遇到类加载器问题,尤其是在使用 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.
OpenJPA - 这是迄今为止最好的文档,易于下载和使用,但它似乎有很多问题。也许它只是我的代码,但我发现更高级用法的代码,例如与 CascadeType.all 设置的 OneToMany 关系似乎不起作用。诚然,这可能是我的代码出错了,我还没有时间测试一个干净的案例,但是很多这样的事件让我不敢使用它。我真的希望它变得更好。它的错误消息在帮助解决问题时通常是无用的。
What other libraries have people used and which ones do they prefer and why?
人们使用过哪些其他图书馆?他们更喜欢哪些图书馆?为什么?
采纳答案by Clint
I had the same conclusions about these implementations.
我对这些实现有相同的结论。
OpenJPA was/seemed buggy
Hibernate had tons of libraries and seemed to have trouble with notlazy loading everything.
- 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.
OpenJPA 曾经/似乎有问题
Hibernate 有大量的库,并且似乎无法延迟加载所有内容。
- Toplink 最终成为我的选择。它不像 Hibernate 那样灵活,但它可以工作,而且我不必安装commons-logging。
The one I would try next is JPOX, which has recently been renamed to datanucleus.
我接下来要尝试的是 JPOX,它最近已重命名为datanucleus。
回答by Chris Dail
Personally I don't feel OpenJPA is mature enough yet. There are other open source libraries that are more mature and I would rather use those. These are the ones I would consider in order:
我个人觉得 OpenJPA 还不够成熟。还有其他更成熟的开源库,我宁愿使用它们。这些是我会按顺序考虑的:
Hibernate. Hibernate has been around for a long time and has really paved the way for ORM in Java. The only issue I have with Hibernate is the licensing. It is LGPL licensed which may cause some commercial companies to squirm (for reasons I won't go into here). Anyway, if LGPL is an issue for you, it is probably good to steer clear.
EclipseLink. Some background on eclipselink. Toplink Essentials was Oracle's free version of their JPA implementation. EclipseLink was taken from Toplink, Oracle's full blown JPA implementation. EclipseLink is going to be the JPA 2.0 provider for Glassfish v3.0 so it looks like everything is moving away from Toplink Essentials and to EclipseLink. Although the EclipseLink version is only 1.0.2, the product has been around for a long time under other names.
休眠。Hibernate 已经存在了很长时间,并为 Java 中的 ORM 铺平了道路。我对 Hibernate 的唯一问题是许可。它是 LGPL 许可的,这可能会导致一些商业公司陷入困境(出于我不会在这里讨论的原因)。无论如何,如果 LGPL 对您来说是个问题,那么避开它可能是件好事。
Eclipse 链接。eclipselink 的一些背景知识。Toplink Essentials 是 Oracle 的 JPA 实现的免费版本。EclipseLink 取自 Toplink,Oracle 的完整 JPA 实现。EclipseLink 将成为 Glassfish v3.0 的 JPA 2.0 提供者,所以看起来一切都从 Toplink Essentials 转移到 EclipseLink。尽管 EclipseLink 版本只有 1.0.2,但该产品已经以其他名称出现了很长时间。
A project I'm working on is on Toplink Essentials right now but we plan to switch to Eclipselink shortly. Hibernate was out for the licensing issues I mentioned earlier.
我正在处理的一个项目是 Toplink Essentials,但我们计划很快切换到 Eclipselink。Hibernate 用于解决我之前提到的许可问题。
回答by Chris Dail
OpenJPA is known as Kodo, which is what BEA bought quite long ago. Kodo was implementation of JDO and now JPA. Also, we use OpenJPA quite intensively. Thus, I woudn't say that it's not mature. It's fine However I would suggest to use Hibernate, namely, JPA wrappers around Hibernate.
OpenJPA 被称为 Kodo,这是 BEA 很久以前购买的。Kodo 是 JDO 的实现,现在是 JPA。此外,我们非常密集地使用 OpenJPA。因此,我不会说它不成熟。很好但是我建议使用 Hibernate,即围绕 Hibernate 的 JPA 包装器。
Reason? 1) JPA is very, very similar to Hibernate 2) Many job positions has Hibernate requirement. It's better to lean to mainstream products...basically
原因?1) JPA 与 Hibernate 非常非常相似 2) 许多职位都有 Hibernate 要求。最好是倾向于主流产品......基本上