Using Spring Data with EclipseLink

How to replace Hibernate with more robust EclipseLink in Spring Boot-based applications

Marian Čaikovski

--

There are two implementations of JPA — Hibernate and EclipseLink. The two libraries have important differences. Hibernate poorly supports relational data with nested one-to-many or many-to-many associations. So for relational data it is easier to use EclipseLink or even JDBC.

The popular Spring Data JPA library uses Hibernate as the default JPA implementation. Because of such a dependency built-in repository method findAll(Sort) or methods decorated with queries cannot return sorted relational data. But it is easy to replace Hibernate with a more capable EclipseLink.

First, you the dependencies in pom.xml have to be adjusted — Hibernate excluded and EclipseLink added:

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<exclusions>
<exclusion>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>…

--

--

Marian Čaikovski

Java, JavaScript and SQL developer. Interested in data collection and visualization.