Win a copy of Modern JavaScript for the Impatient this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Difference between JPA and Hibernate

 
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?
 
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
 
ranger
Posts: 17346
11
Mac IntelliJ IDE 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
 
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
 
I'm so happy! And I wish to make this tiny ad happy too:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic