Hibernate vs Eclipselink

Asked

Viewed 1,598 times

5

Both persistence frameworks implement JPA.

1 - There is a difference between the two?

2 - Which is the best in performance?

3 - As the two implement the same specification, after developing a complete application it is possible to change from one framework to another without needing major changes in the source code?

3 answers

4


Both persistence frameworks implement JPA.

1 - There is a difference between the two?
Yes, there are differences.
However, common sense understands that the purpose is the same: both implement the JPA specification.
Hibernate was born without JPA but nowadays it is common to access Hibernate by the JPA specification: we can mention: Jboss hibernate, Eclipse Foundation Eclipselink and Apache Openjpa. Although Hibernate originated JPA, Eclipselink is the referential implementation. [Hibernate - Frameworks ORM]


2 - Which is the best in performance?
Eclipselink provides much more sophisticated and exotic layers and cache capabilities, as isolated cache storage for virtual private database support (virtual private database - vpd). What’s more, In the case of Eclipselink, it has a fully integrated shared object cache, so not only is local persistence context management efficient, but also all threads on the same server can benefit from the shared cache content. [Pro JPA 2]


3 - As the two implement the same specification, after developing a complete application it is possible to change from one framework to another without needing major changes in the source code?
In theory, yes, you should. The main query language is Java Persistence Query Language (JP QL), a database-independent query language that operates in the logical entity model as opposed to the physical data model. But in practice it will depend on the Native SQL dialect used in the lines of code (not recommended). Before languages like JP QL became standardized, the most common method for building queries across many persistence providers was through a programming API. The query structure in Eclipselink, for example, was the most effective way to truly unlock the full power of your query mechanism. And even with the advent of JP QL, the programming Apis still remained in use to give access to features not yet supported by the standard query language. [Pro JPA 2]


I believe that’s it, and I’m sorry if I was somehow biased. It wasn’t my intention.

References:


[JPA specification]. Available in JSR-000338: Java(tm) Persistence Specification. Accessed: 31 Mar 2017.

[Hibernate - Frameworks ORM]. Available in Java Web Workbook: A Practical Introduction to JPA with Hibernate. Accessed: 31 Mar 2017.

[Pro JPA 2]. Available in Pro JPA 2 - A Definitive Guide to Mastering the Java Persistence API. Accessed: 31 Mar 2017.

3

  1. yes there is difference in behavior between the two, but only where the specification does not make clear what should be done, follow the links for more information. http://blog.caelum.com.br/jpa-hibernate-ou-eclipselink/ http://blog.caelum.com.br/jpa-2-curiosidades-nas-implementacoes-parte-2/
  2. In general Hibernate usually presents a succinctly better performance, follows the link with a comparative. http://www.jpab.org/Hibernate/MySQL/server/EclipseLink/MySQL/server.html
  3. In general you should change little code, but specific behaviors of when switching from one to another may end up playing a few tricks, such as the Hibernete ID filled in just after calling the Eclipselink percist methods only when the record is sent to DB.

2

Hibernate is more rugged, consumes more memory and so can be considered heavier, but under extreme conditions it is more efficient by doing much more Inserts and queries per minute. Use it in projects where you have a robust server and simultaneous access is great.

Toplink and Eclipselink are for simpler projects. They are lighter in memory and great for JPA learning because it will be difficult to lock your machine, but they cannot withstand the trance that Hibernate endures in more critical moments in production server.

This is not just an opinion of mine based on personal experience. I’ve heard the same comments from other programmers and post teachers. In the link below the author of the post made some tests that corroborate this perception of Eclipselink and Toplink being less robust than Hibernate: http://terrazadearavaca.blogspot.com.br/2008/12/jpa-implementations-comparison.html

In terms of usage, they all use JPA and if you don’t use any implementation-specific functionality, to swap you’ll only need to change properties in the persistence xml and half a dozen Imports.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.