aspose file tools*
The moose likes Other Application Frameworks and the fly likes Difference between JPA and Hibernate Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "Difference between JPA and Hibernate" Watch "Difference between JPA and Hibernate" New topic
Author

Difference between JPA and Hibernate

Em Aiy
Ranch Hand

Joined: May 11, 2006
Posts: 226
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?


The difference between <b>failure</b> and <b>success</b> is often being <b>right</b> and being <b>exactly right</b>.
Lalit Bhatt
Ranch Hand

Joined: Dec 27, 2007
Posts: 69

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.


Java-JavaEE Hibernate Spring Software Development Business Process Analysis
Lalit Bhatt
Ranch Hand

Joined: Dec 27, 2007
Posts: 69

Rather than using mappings in XML file, use annotations. See a tutorial of JPA support by Hibernate here
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

Hibernate implements the JPA spec, and a whole lot more that the spec doesn't cover.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Hong Anderson
Ranch Hand

Joined: Jul 05, 2005
Posts: 1936
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).


SCJA 1.0, SCJP 1.4, SCWCD 1.4, SCBCD 1.3, SCJP 5.0, SCEA 5, SCBCD 5; OCUP - Fundamental, Intermediate and Advanced; IBM Certified Solution Designer - OOAD, vUML 2; SpringSource Certified Spring Professional
Hong Anderson
Ranch Hand

Joined: Jul 05, 2005
Posts: 1936
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

Joined: May 11, 2006
Posts: 226
Thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Difference between JPA and Hibernate