JPA - Providers
Providers
EclipseLink and Hibernate
You need a JPA provider, if you want to use the JPA specification in your project. It implements the interfaces as defined by the specification. The most popular ones are EclipseLink and Hibernate.
One advantage of the standardized API provided by JPA is that you just need to add its implementation at runtime and that you can replace it with a different one without changing any code. The standardized API makes EclipseLink and Hibernate interchangeable.
So, why do you need different implementations?
The JPA implementations are managed by independent teams, and you can choose the one that provides the best performance or support for your application and technology stack. They also differentiate themselves by providing additional, non-standard functionalities. This is often used to drive innovation. Today’s popular, proprietary feature might be the first step to the next addition to the JPA standard. Using any of these proprietary features, obviously, makes it a lot harder to replace a specific JPA implementation.
EclipseLink
EclipseLink is JPA’s reference implementation and implements JPA version 2.2. It was one of the first projects that became part of EE4J.
The easiest way to add EclipseLink to your project is to use the following Maven coordinates.
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>eclipselink</artifactId>
<version>2.7.1</version>
</dependency>
Interesting proprietary features
In addition to the features defined by the JPA standard, EclipseLink also offers several interesting, proprietary features, like:
- Handling of database change events
- Composite persistence units to map entities to tables in multiple databases
- Support for multi-tenancy
Hibernate
Hibernate is Red Hat’s very popular implementation of the JPA specification. It implements almost all features defined by JPA 2.2 and will release a fully compliant version soon.
The following Maven dependency adds Hibernate to your project.
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.1.11</version>
</dependency>
Interesting proprietary features
Similar to EclipseLink, Hibernate provides a bunch of interesting, proprietary features, like:
- Extended support for natural IDs
- Loading multiple entities by their primary key
- Management of creation and update timestamps
- Joining unassociated entities in queries
- Support for multi-tenancy
Reference
https://thorben-janssen.com/difference-jpa-hibernate-eclipselink/