Search code examples
hibernatejpajakarta-eepersistencejava-ee-5

Which are the differences/similarities between hibernate and other frameworks or specifications?


I want to know the differences/similarities between Hibernate and simple persistence in Java EE 5?

I'm not clear if Hibernate implements Java EE 5 persistence implementation or if it is a totally different approach to data representation over back-end systems.

I'm confused about Hibernate and its relation with the concepts about java persistence given in the Java EE 5 tutorial... could you clarify the role of Hibernate in the context of Entities and EJBs?

Also, I want to know other approaches (frameworks) like JPA or Spring...


Solution

  • I want to know the differences/similarities between Hibernate and simple persistence in Java EE 5?

    The standardized persistence API of Java EE 5 is JPA 1.0 and is a kind of unified version of EJB 2 CMP, JDO, Hibernate, and TopLink APIs and products. Hibernate is an ORM framework that predates JPA and has heavily influenced the specification of JPA (the creator of Hibernate is a member of the expert group behind JPA). Just keep in mind that JPA is just an API, you need an implementation of JPA to use it.

    I'm not clear if Hibernate implements Java EE 5 persistence implementation or if it is a totally different approach to data representation over back-end systems.

    Yes, Hibernate provides an implementation of JPA (and also extends it, Hibernate is a superset of JPA) via the Hibernate EntityManager project (that relies on Hibernate Core).

    I'm confused about Hibernate and its relation with the concepts about java persistence given in the Java EE 5 tutorial... could you clarify the role of Hibernate in the context of Entities and EJBs?

    Hibernate can be used as the JPA persistence provider, i.e. as the piece of code that actually persists EJB 3 entities (the JPA specification was part of EJB 3.0 specification in version 1.0, it's now a separate spec)

    Also, I want to know other approaches (frameworks) like JPA or Spring...

    Spring is not a persistence framework, Spring is an IoC container, it doesn't compete with Hibernate.

    JPA compliant alternatives to Hibernate include TopLink Essentials (the RI in Java EE 5), EclipseLink (which is also the RI of JPA 2.0 in Java EE 6), OpenJPA, DataNucleus.

    Other options for persistence include JDO (another standardized persistence API), iBATIS (not an ORM, it's more a data mapper), JDBC (low level API) to cite the most famous.

    Check this previous answer for an overview and some historical background.