• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Difference between Hibernate and JPA

 
Ranch Hand
Posts: 119
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How much is the difference between Hibernate and JPA at API level? Can I easily covert an application that use Hibernate to JPA? or vise verse?
Is it wise to select JPA over Hibernate for a fresh new application? I want to go with the standard JPA.

What about iBatis?

Thanks
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"The Jain",
Welcome to the JavaRanch.

We're a friendly group, but we do require members to have valid display names.

Display names must be two words: your first name, a space, then your last name. Fictitious names are not allowed.

Please edit your profile and correct your display name since accounts with invalid display names get deleted.
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hibernate implements JPA. So if you use all the class packages of jpa, you can use Hibernate as the implementation of it.

JPA is a spec and not an implementation, so if you choose JPA, you still have to pick an implementation. You can pick Hibernate, Toplink, and any other ORM that implements JPA.

I hope that helps clear things up.

If you find you have an import that is org.hibernate.xxx, then you know you are using something that is Hibernate specific that is not in the JPA spec.

Mark
 
Tejas Jain
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Mark Spritzler:

Hibernate implements JPA. So if you use all the class packages of jpa, you can use Hibernate as the implementation of it.

...

If you find you have an import that is org.hibernate.xxx, then you know you are using something that is Hibernate specific that is not in the JPA spec.

Mark



I did not see Hibernate has a package called "javax.persistence" in the Hibernate download. Hibernate provides another product called EJB3 JPA implementation. I would like to know the difference between JPA and original Hibernate specific implementations. Thanks
[ March 14, 2008: Message edited by: Todd Jain ]
 
Tejas Jain
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mark, You still did not answer my question.
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Todd Jain:


I did not see Hibernate has a package called "javax.persistence" in the Hibernate download. Hibernate provides another product called EJB3 JPA implementation. I would like to know the difference between JPA and original Hibernate specific implementations. Thanks

[ March 14, 2008: Message edited by: Todd Jain ]



Hibernate implements JPA, you need all the correct Jars. Hibernate has implementations of javax.persistence classes.

Mark
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry, also, I was up at Mammoth Mountain Snowboarding this past weekend.

Mark
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Friends, Even I have similar doubt about Hibernate 3.
My assumption is hibernate has two types of implementations (1) as a implmenetation of JPA (2) The extension to older hibernate (Without JPA). If we use first case we would have to use query language/syntex provided by JPA whie in second case we would have to use HSQL. and once we write HSQL queries we can't switch to JPA implementation.
Guys, please let me know is it correct ?
 
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JPA is the subclass of Hibernate. It retains properties of hibernate. Hibernate is the Persistence provider and JPA is the API to implement it. Lets take a example of JDBC API in java and mysql. We use DriverManager.getConnection to get the connection which is defined in Java API but still we need to use mysql jar to connect to the database.

JPA and hibernate works on same principle. JPA is specification and Hibernate is implementation. As per my understanding JPA is better approach to use compare to Hibernate in future migration.
 
Gauravv Gupta
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Sunil, I agree with your reply. But could you share when HQL comes in the picture since JPA has its own query language? Or is it like while implementing hibernate its upto the programmer with QL to use ?
 
xsunil kumar
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Gaurav, i will try to get back your answer.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"Gaurav Gg", please check your private messages for an important administrative matter.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think it's likely that Hibernate transforms JPA's QL into HQL before executing it. Seems less work than having two separate QL -> SQL transformation engines.
 
Ranch Hand
Posts: 210
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As Mark had mentioned before, JPA is just a specification while Hibernate is one of the implementations..
For an application server to be J2EE compliant, it should support JPA...so what that means is that all the application Servers like Weblogic, Websphere, Jboss etc should implement JPA...
Now, how these servers implement JPA depends on them..eg Jboss implements JPA using Hibernate...while some other server may use some other ORM framework like Toplink..
So...if you are just using JPA on a Jboss server...and some exception comes, related to the persistence layer...you can easily see the stacktrace having hibernate in it...although we did not use Hibernate(because Jboss internally uses hibernate for JPA impl )..

and EJBQL is converted to HQL(or the query language of other ORM framework).
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic