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

4

0

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...

Coupler answered 27/4, 2010 at 16:57 Comment(0)
M
4

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.

Myatt answered 27/4, 2010 at 22:52 Comment(0)
M
1

When JPA (Java EE 5 persistence standard) was developed by the JCP expert group (JSR 220) a lot of ideas have been taken from the existing Hibernate (also from JDO). Gavin King the founder of Hibernate himself has been part of the expert group among others.

After the final JPA specification was published Hibernate became an open source implementation of it (since version 3.2). Hibernate still has a richer feature set and usually generates new features faster as an open-source development process tend to be faster then a Java community process.

Other implementations of JPA are:

  • DataNucleus
  • EclipseLink
  • OpenJPA

Other approaches are:

  • JDO
  • iBatis
  • plain JDBC
Mcgraw answered 27/4, 2010 at 22:51 Comment(0)
I
0

The JPA specification described in EE5 is just an specification. This means that it is not a product. JPA is just a set of definitions that the different providers have to accomplish to be "JPA complaint"

Hibernate is just another "plugable" persistence provider, this means that this product implements the definitions given by JPA specification. You can find other similar products like TopLink or Apache's OpenJPA.

That is it.

Invite answered 27/4, 2010 at 22:58 Comment(0)
N
0

Slightly off topic but JPA implies a "session orientated" architecture. That is your beans are attached/detached to an EntityManager and you persist/merge/flush the entityManager.

If you are looking for a "sessionless" approach to ORM (no attached/detached persist/merge/flush) then you can also look at Ebean ORM which also uses JPA Annotations for mapping. You could also describe this as "Ebean provides automatic management of the Persistence Context".

Nationalism answered 5/5, 2010 at 22:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.