JPA Implementations - Which one is the best to use?

mxc picture mxc · Feb 23, 2009 · Viewed 45.4k times · Source

I have made use of the following JPA implementations:

  1. Hibernate,
  2. Toplink,
  3. OpenJPA

Each of them has their own strengths and weaknesses. I found Hibernate the most advanced of the three except that it mixed some of its own enhancements with JPA which made it difficult to switch out to other providers. Most importantly, its query parser was much more lenient when interpreting JPA. They make it slightly difficult to get the correct libraries to support hibernate because I found it a mission trying to get the right versions of all the dependencies.

Toplink was ok but one is left with the feeling that it is slightly crippled as it seems Oracle wants you to use/buy? their more advanced library. Trying to download it was also a mission because you need to install it via running a jar file. I found that it implemented only the base JPA spec. The reason I used it was hibernate uses a lot of libraries that are commonly used in other open source projects that one would often get classloarder problems, especially when using JBoss

OpenJPA - This has by far the best documentation and is easy to download and use but it seems its very buggy. Maybe its just my code but code I found more advanced usage such as OneToMany relationships with CascadeType.all set just didn't seem to work. Admittedly It may be my code that was wrong and I haven't had time to test a clean case but many incidents like this leave me scared to use it. I really hope it gets better. Its error messages are often useless in helping solve the problem.

What other libraries have people used and which ones do they prefer and why?

Answer

Clint picture Clint · Feb 23, 2009

I had the same conclusions about these implementations.

  1. OpenJPA was/seemed buggy

  2. Hibernate had tons of libraries and seemed to have trouble with not lazy loading everything.

  3. Toplink ended up as my choice. It was not as flexible as Hibernate would have been but it works and I don't have to install commons-logging.

The one I would try next is JPOX, which has recently been renamed to datanucleus.