15

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?

jfcorugedo
  • 9,793
  • 8
  • 39
  • 47
  • 3
    I never tried it in combination with Spring - but Hibernate Bean validation and EclipseLink are used in Glassfish.... so usability is proven. I also *prefer* EclipseLink to Hibernate because it automatically supports an extended open session for lazy loading. – cljk Oct 06 '13 at 21:30
  • 1
    All JPA 2 implementations (if compliant) will allow use of ANY Bean validation implementation. And if something is a "reference implementation" it means that was used as a way of proving that the JPA spec is implementable ... *nothing more*. – DataNucleus Oct 08 '13 at 07:32
  • Possible duplicate of [Hibernate or EclipseLink for JPA?](http://stackoverflow.com/questions/3234829/hibernate-or-eclipselink-for-jpa) – Dinei May 08 '17 at 17:36

1 Answers1

11

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.

Debojit Saikia
  • 10,532
  • 3
  • 35
  • 46