JPA Implementations - Which one is the best to use?

45,613

Solution 1

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.

Solution 2

Personally I don't feel OpenJPA is mature enough yet. There are other open source libraries that are more mature and I would rather use those. These are the ones I would consider in order:

  1. Hibernate. Hibernate has been around for a long time and has really paved the way for ORM in Java. The only issue I have with Hibernate is the licensing. It is LGPL licensed which may cause some commercial companies to squirm (for reasons I won't go into here). Anyway, if LGPL is an issue for you, it is probably good to steer clear.

  2. EclipseLink. Some background on eclipselink. Toplink Essentials was Oracle's free version of their JPA implementation. EclipseLink was taken from Toplink, Oracle's full blown JPA implementation. EclipseLink is going to be the JPA 2.0 provider for Glassfish v3.0 so it looks like everything is moving away from Toplink Essentials and to EclipseLink. Although the EclipseLink version is only 1.0.2, the product has been around for a long time under other names.

A project I'm working on is on Toplink Essentials right now but we plan to switch to Eclipselink shortly. Hibernate was out for the licensing issues I mentioned earlier.

Share:
45,613
mxc
Author by

mxc

A Linux solutions, Java and PHP developer.

Updated on February 04, 2020

Comments

  • mxc
    mxc over 4 years

    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?

  • Lordn__n
    Lordn__n about 15 years
    EclipseLink is (imho) better than all of those.
  • user3111525
    user3111525 over 10 years
    what about objectdb? www.objectdb.com
  • Mohsen Kashi
    Mohsen Kashi about 10 years
    or EBean! avaje.org
  • Marco Dinatsoli
    Marco Dinatsoli over 8 years
  • Ankit
    Ankit over 8 years
    This was answered in 2009. What is the preferred JPA implementation nowadays?
  • Gab是好人
    Gab是好人 over 7 years
    Lazy loading is the default as of Hibernate 3.