Java 用于 JPA 的 Hibernate 或 EclipseLink?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3234829/
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
Hibernate or EclipseLink for JPA?
提问by Ta Sas
I was wondering if anyone has experience with the JPA2.0 implementation of any of those frameworks? Especially together with Spring3.x which comes with EclipseLink support.
我想知道是否有人对这些框架的 JPA2.0 实现有经验?特别是与带有 EclipseLink 支持的 Spring3.x 一起使用。
Do you use any of those frameworks and JPA2.0 for production? Any severeissues?
您是否使用任何这些框架和 JPA2.0 进行生产?有什么严重的问题吗?
采纳答案by Peter Krogh
IMHO It is always better to use a standard api where possible. Your own example shows this perfectly. You were able to try your identical code on two providers when one failed to work as expected. Switching to any native API prevents you from doing this.
恕我直言,在可能的情况下使用标准 api 总是更好。你自己的例子完美地展示了这一点。当一个提供程序未能按预期工作时,您可以在两个提供程序上尝试相同的代码。切换到任何本机 API 都会阻止您这样做。
If using EclipseLink as your JPA 2.0 provider works well for you, then use it. If you do happen to run into an issue, file an EclipseLink bug, and get help on this forum, or the EclipseLink forums and Newsgroups.
如果使用 EclipseLink 作为您的 JPA 2.0 提供程序对您来说效果很好,那么请使用它。如果您碰巧遇到问题,请提交 EclipseLink 错误,并在此论坛或 EclipseLink 论坛和新闻组上获得帮助。
回答by Timo Westk?mper
EclipseLink is more standards compliant, since it is the reference implementation for JPA 2, Hibernate has some compliancy issues, but is more mature.
EclipseLink 更符合标准,因为它是 JPA 2 的参考实现,Hibernate 有一些兼容性问题,但更成熟。
One of the main benefits of EclipseLink is that you can call native SQL functions directly in your JPQL queries. In Hibernate this is not directly possible.
EclipseLink 的主要优点之一是您可以直接在 JPQL 查询中调用本机 SQL 函数。在 Hibernate 中,这不是直接可能的。
But Hibernate has a bigger community, better documentation and also better error messages.
但是 Hibernate 拥有更大的社区、更好的文档和更好的错误消息。
回答by Tunde Pizzle
From my experience, with Java Perf Profiling. My apps built using Eclipselink seem to perform a lot better than with Hibernate both in Data insertion and retrieval. Hibernate however is more widely used and provides a bigger forum for support.
根据我的经验,使用 Java Perf Profiling。我使用 Eclipselink 构建的应用程序在数据插入和检索方面的性能似乎比使用 Hibernate 好得多。然而,Hibernate 使用更广泛,并提供了更大的支持论坛。
In production, I will simply take Hibernate for this reason.
在生产中,出于这个原因,我将简单地采用 Hibernate。
回答by Archimedes Trajano
Just pick and stick with one. Standards are just in the end guidelines and every implementer can implement or fail to implement the standards accordingly.
只需选择并坚持一个。标准只是最终的指导方针,每个实施者都可以相应地实施或不实施标准。
e.g.
例如
EclipseLink has issues using something basic such as JPA
@Converter
s though supposedly recently fixed through IBM http://www-01.ibm.com/support/docview.wss?uid=swg1PI73277Hibernate's JPQL implementation does not understand boolean values that stand on their own more specifically I had to change my JPQL to say
from Participant p where not p.cancelled
to
from Participant p where p.cancelled = false
EclipseLink 使用一些基本的东西(例如 JPA )有问题,
@Converter
尽管据说最近通过 IBM http://www-01.ibm.com/support/docview.wss?uid=swg1PI73277Hibernate 的 JPQL 实现不理解更具体的布尔值,我不得不改变我的 JPQL 说
from Participant p where not p.cancelled
到
from Participant p where p.cancelled = false
The other thing is you're building things in Spring and you're likely going to do the improper but common approach of changing the class loader to PARENT_LAST
order so your classes are used rather than the application servers.
另一件事是您正在 Spring 中构建东西,并且您可能会采用不正确但常见的方法来更改类加载器以进行PARENT_LAST
排序,以便使用您的类而不是应用程序服务器。
If you plan to do the proper way and use the JPA that comes with the application server just be a bit wary in that your Application Server implementation may be buggy.
如果您打算以正确的方式使用应用程序服务器附带的 JPA,请注意您的应用程序服务器实现可能有问题。
Transaction wise your application, specifically Spring must handle things for you.
事务明智您的应用程序,特别是 Spring 必须为您处理事情。