Java 休眠与 EclipseLink
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19214001/
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 vs EclipseLink
提问by jfcorugedo
I'm starting a new Web project and I've chosen JPA as my persistence ORM engine.
我正在启动一个新的 Web 项目,并选择 JPA 作为我的持久性 ORM 引擎。
Although I've used OpenJPA in my last project, now I want to use EclipseLink.
虽然我在上一个项目中使用了 OpenJPA,但现在我想使用 EclipseLink。
Why? It is the JPA reference implementation, it has a lot of documentation and a very good support in the Eclipse IDE. Also, I can't found any benchmark that declares none of them to be the best, so performance is not a factor (all implementations has its own strength points).
为什么?它是 JPA 参考实现,在 Eclipse IDE 中有大量文档和非常好的支持。此外,我找不到任何声明它们都不是最好的基准测试,因此性能不是一个因素(所有实现都有自己的优势点)。
But, I want to use the JSR-303 validation spec, and I've chosen hibernate-validator (witch is the reference implementation of the Bean Validation spec).
但是,我想使用 JSR-303 验证规范,并且我选择了 hibernate-validator(witch 是 Bean 验证规范的参考实现)。
Moreover, I'm using Spring, and there are a lot of examples with Spring+Hibernate, but I haven't found any opinion that said Spring is better with Hibernate.
而且,我用的是Spring,有很多Spring+Hibernate的例子,但是我还没有发现任何说Spring用Hibernate更好的意见。
Is there any problem mixing this two implementations? Would be better to use Hibernate JPA with Hibernate Bean validation?
混合这两种实现有什么问题吗?将 Hibernate JPA 与 Hibernate Bean 验证一起使用会更好吗?
采纳答案by Debojit Saikia
I have been using EclipseLink
implementation of JPA with Spring and Hibernate-validation-4.2.0.Final
. And no problem so far. Now to answer your question:
我一直在使用EclipseLink
Spring 和Hibernate-validation-4.2.0.Final
. 到目前为止没有问题。现在回答你的问题:
Is there any problem mixing this two implementations?
混合这两种实现有什么问题吗?
I don't think there will be any problem using EclipseLink
JPA implementation with Hibernate
implementation for JSR-303 validation spec together, as the purpose of these two specifications are different:
我认为将EclipseLink
JPA 实现与Hibernate
JSR-303 验证规范的实现一起使用不会有任何问题,因为这两个规范的目的不同:
- JSR 303 - Bean Validation - defines a metadata model and API for entity validation. This is not tied to a specific application tier or programming model.
- JPA - This is the specification of the Java API for the management of persistence and object/relational mapping with Java EE and Java SE.
- JSR 303 - Bean Validation - 定义了用于实体验证的元数据模型和 API。这与特定的应用程序层或编程模型无关。
- JPA - 这是 Java API 的规范,用于使用 Java EE 和 Java SE 管理持久性和对象/关系映射。
Spring provides full support for the JSR-303 Bean Validation API. You just need to have a JSR-303 provider, such as Hibernate Validator, present in the classpath and will be detected automatically.
Spring 完全支持 JSR-303 Bean Validation API。您只需要在类路径中存在一个 JSR-303 提供程序,例如 Hibernate Validator,并且会被自动检测到。
And the Spring JPA, available under the org.springframework.orm.jpa
package, offers comprehensive support for the Java Persistence API
in a similar manner to the integration with Hibernate
.
org.springframework.orm.jpa
包下提供的 Spring JPAJava Persistence API
以类似于与Hibernate
.