• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Difference between JPA and Hibernate

 
Em Aiy
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
While going through some tutorials, i got confuse between JPA and Hibernate. JPA is often being referred as "presistence" framework. if it is for presistance then wat is hibernate for?

secondly, if we are using JPA (backend mysql) then do we require to have all those <table_name>.hbm.xml file for hibernate? what are the pro and cons for JPA and using JPA with hibernate?
 
Lalit Bhatt
Ranch Hand
Posts: 69
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hibernate made the ORM concepts very popular. It is an open source project. To bring the concept of ORM into Java standards, EJB3.0 was introduced. For persistence EJB3.0 has adopted ORM concepts in the form of Entity beans and JPA. Hibernate than went ahead and supported the EJB3.0 specification also.

In nutshell you can say JPA and entity Beans are specifications and Hibernate is an implementation.
 
Lalit Bhatt
Ranch Hand
Posts: 69
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rather than using mappings in XML file, use annotations. See a tutorial of JPA support by Hibernate here
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hibernate implements the JPA spec, and a whole lot more that the spec doesn't cover.

Mark
 
Hong Anderson
Ranch Hand
Posts: 1936
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Lalit Bhatt wrote:To bring the concept of ORM into Java standards, EJB3.0 was introduced. For persistence EJB3.0 has adopted ORM concepts in the form of Entity beans and JPA. Hibernate than went ahead and supported the EJB3.0 specification also.

No, No, No.

1st no, the goal of EJB 3 is to simplify Java EE development, at first regarding persistence, they wanted to simplify EJB CMP, but they found that it's too much work, so they decided to use an other approach, that was JPA, and did nothing to EJB CMP.

2nd no, Entity beans in EJB 3 are the same as Entity beans in EJB 2.x, JPA uses POJOs, not Entity beans.

3rd no, Hibernate supports JPA, not entire EJB 3 specification (JPA specification is a part of EJB 3 specification).
 
Hong Anderson
Ranch Hand
Posts: 1936
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Muhammad Ali wrote:While going through some tutorials, i got confuse between JPA and Hibernate. JPA is often being referred as "presistence" framework. if it is for presistance then wat is hibernate for?

I suggest to read http://java.sun.com/javaee/overview/faq/persistence.jsp.
Muhammad Ali wrote:
secondly, if we are using JPA (backend mysql) then do we require to have all those <table_name>.hbm.xml file for hibernate?

No need.
 
Em Aiy
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic