30

I want to use the Java Persistence API (JPA) for my web application.

There are popular JPA implementations like Hibernate, Toplink and EclipseLink. What implementation is a good choise and why?

Dimitri Dewaele
  • 9,061
  • 17
  • 67
  • 116
  • 2
    Your first choice should always be the one that comes bundled with your appserver, as it will be the easiest to work with, IMO – fvu Jul 26 '13 at 14:28

1 Answers1

62

When the Java Persistence API (API) was developed, it became popular very fast. JPA describes the management of relational data in applications using Java.

JPA (Java Persistence API) is an interface for persistence providers to implement.

Hibernate is one such implementation of JPA. When you use Hibernate with JPA you are actually using the Hibernate JPA implementation.

JPA typically defines the metadata via annotations in the Java class. Alternatively via XML or a combination of both. A XML configuration overwrites the annotations.

JPA implementations:

  • Hibernate: The most advanced and widely used. Pay attention for the classpath because a lot of libraries are used, especially when using JBoss. Supports JPA 2.1.
  • Toplink: Only supports the basic JPA specs. (This was oracle’s free version of the JPA implementation)
  • EclipseLink: Is based on TopLink, and is the intended path forward for persistence for Oracle and TopLink. Supports JPA 2.1
  • Apache OpenJPA: Best documentation but seems very buggy. Open source implementation for JPA. Supports JPA 2.0
  • DataNucleus: Well documented, open source (Apache 2 license), is also a JDO provider. Supports JPA 2.1
  • ObjectDB: well documented
  • CMobileCom JPA: light-weight JPA 2.1 implementation for both Java and Android.

Other approaches are:

  • Plain JDBC
  • ORM with Hibernate: Hibernate is now also very supportive for JPA
  • iBatis: The project moved to MyBatis (link)
  • JDO

Motivation for Hibernate as my JPA choice:

  • Mature project:
    • Most advanced
    • Well documented
  • Useful Hibernate sub projects
    • Hibernate tools: automatic generation of code and database generation
    • Hibernate validation: bean specification capabilities. Integrates with JPA2
    • Hibernate search: powerful full-text search on domain objects
  • Active community
    • Big development community
    • Widely used

Hibernate became an open source implementation of JPA very fast after the final specification was published. It has a rich feature set and generates new features fast, because an open-source development process tend to be faster then a Java community process.

Zoey Mertes
  • 2,789
  • 15
  • 23
Dimitri Dewaele
  • 9,061
  • 17
  • 67
  • 116
  • 1
    Toplink [is a very mature ORM product](http://en.wikipedia.org/wiki/TopLink) that predates JPA by almost a decade. Toplink Essentials was the reference implementation for JPA 1. Toplink and Toplink Essentials are very different products. – fvu Jul 26 '13 at 14:31
  • 8
    "most advanced" ? lol. I can name many features present in other JPA impls (e.g DataNucleus JPA, EclipseLink) that Hibernate doesn't have. Doesn't mean that Hibernate isn't good at some things, but blanket statements like that are (part of) the reason why questions of this nature don't fit on this site. Here you are answering your own question, so maybe its just a FUDDing exercise against other tools? – Neil Stockton Jul 27 '13 at 11:15
  • 1
    With [67% market share](http://zeroturnaround.com/rebellabs/java-tools-and-technologies-landscape-for-2014/), it means that all the other providers combined are used by less than half of Hibernate users. That tells a lot. – Vlad Mihalcea Jul 21 '16 at 12:07
  • 4
    market share tells you nothing about how good something is. Make your own mind up based on your application and the features you need. – Neil Stockton Oct 16 '16 at 07:36
  • To make this answer more complete: [CMobileCom JPA](http://cmobilecom.com) is a light weight JPA 2.1 implementation for both Java and Android. About 380K. – John Sep 09 '18 at 03:27