Hibernate vs EclipseLink

jfcorugedo picture jfcorugedo · Oct 6, 2013 · Viewed 16.3k times · Source

I'm starting a new Web project and I've chosen JPA as my persistence ORM engine.

Although I've used OpenJPA in my last project, now I want to use 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).

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).

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.

Is there any problem mixing this two implementations? Would be better to use Hibernate JPA with Hibernate Bean validation?

Answer

Debojit Saikia picture Debojit Saikia · Oct 7, 2013

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:

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:

  • 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.

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.

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.