My colleague just asked me this question and i thought its quite a common question in, lot of developers mind.
Well as you might aware of now we have a much leaner and easy to use Ejb 3 specifications.
The EJB 3.0 specififcation is divided into two parts the first which deals with session and MDBs and the second which deals with persistence and entity beans.
This later part is know as JPA.And as i say latter part so this is independent of session and other concepts.This means that this can be used outside of any Server or managed Container .You can use JPA in SDK just like you write “Hello World”,no need of any Server or container.
JPA works with normal java beans so your code can be just Java beans ,some XML/annotatons about how Object’s are mapped with tables and you are good to go,very easy to write test cases as well.
And hibernate 3.0 implements the JPA specification so TopLink and other O/R mapping framework.So your code depends upon JPA Api and its implementation is supplied by any JPA impl vendor framework.
So in effect if you use JPA , you are using a standard Java Api and not some orthogonal Api and hence you have flexibility in your system.
Say initially you have used Hibernate but now want to shift to Other framework.That means JPA supports pluggable persistence providers.
JPA specification is heavily influenced by current O/R mapping frameworks like Hibernate and Top-Link .
So if i need to put in Concise words:
a) JPA is Persistence Api which your code should use.
b) JPA Api will pass on the call to actual peristence provider (ex:Hibernate/TopLink) to do the actual work.
c) If you are looking from Performance prespective ,it will be dependent on actual peristence provider (Hibernate/TopLink) and not on JPA as its just a wrapper layer.
d) If you are looking from code dependency prespective ,JPA makes more sense as your code is dependent on standard Java Api.
e) If you have used Hibernate then you will find that certain features are missing in JPA like criteria queries etc.This does not mean that you can’t write criteria query in your application, you need to get Session object from JPA Entity manager and now you are as good as in hibernate project.
But now your code is dependent on Specific impl (Hibernate),going forward you can see more things getting added in JPA (2.0)
f) Should you use JPA: My take is you should ,API is clean and although not everthing you need is their but is a good step forward.
Hopefully this give better picture as where all these pieces fits into an Java based Enterprise Application .
good explanation
Comment by lavanya — July 6, 2008 @ 5:18 am |
Excellent, short and simple explanation.
Comment by Petar — July 29, 2008 @ 10:50 pm |
Explanation Defines nothing specific
Comment by y — October 24, 2008 @ 7:18 am |
Very good explanation.Keep this blog live.
Comment by Jagrut — March 10, 2009 @ 5:41 pm |
Simple et efficace. Merci.
Comment by anthony — April 29, 2009 @ 12:48 pm |
Good explanation…
Comment by Selvaraj — June 27, 2009 @ 11:30 am |
Nice concise explanation. Thank you.
Comment by kush_2207 — July 20, 2009 @ 2:25 am |
Nice and simple explanation. Thanks a lot.
Comment by Sreekar — July 23, 2009 @ 6:21 pm |
Great.. Helped me out
Comment by Francois — August 13, 2009 @ 12:49 pm |
Thx !
nice one
Comment by JacQ — October 26, 2009 @ 5:15 pm |
Nice and simple, appreciate it!!
Comment by Sun — November 29, 2009 @ 8:22 pm |
Nice one
Comment by Amit — December 28, 2009 @ 7:37 am |
HI, really nice. I need this badly
Thanks My dear friend khangharoth
Comment by Palam — February 17, 2010 @ 5:27 pm |
Thanks! Now everything is clear!
Comment by Alessandro — February 18, 2010 @ 11:33 am |
This is simple and good explanation
Comment by mahesh — April 16, 2010 @ 6:46 am |
Awesome explanation, very easy and basic explanation that really helped me.
Thanks and keep up the good work
Comment by Ravi Verma — October 10, 2010 @ 3:19 pm |
Thanks for your explanation, it was quite beneficial.
Comment by Vikas Kumar Gupta — October 21, 2010 @ 7:14 am |
I don’t think it is useful…
Comment by Karthi — November 11, 2010 @ 4:20 pm |
Does it mean that you already know the content of this article (good for you in this case), and you are looking for other information?
Comment by muoicairangkhenh — June 9, 2011 @ 8:35 am |
Nice explanation
Comment by Praveen — November 15, 2010 @ 6:29 am |
Nice explanation – But Business need always having higher priority over Standards. But following standards also help us to meeting business need.
Its chicken egg – I always try to follow JPA standards but always i found some place where i need to used implement specific feature.
Comment by kaushik vira — December 16, 2010 @ 7:19 am |
Thank you for good informative explanation.
Comment by Hemang — January 16, 2011 @ 6:34 am |
Great, this explains that Hibernate implements JPA!
What about the other side of the medal – what is in Hibernate that is missing in JPA?
Comment by Rou — February 16, 2011 @ 12:16 pm |
HI
This is very clear explanation for freshers who don’t know the different frameworks and what is JPA
But one request that will u update the answer with new features.
Comment by Krishna Ganesh — February 28, 2011 @ 9:05 am |
Best explanation ever ,so simple and clear.
Comment by Seerat — March 13, 2011 @ 6:57 pm |
Excellent article!
Thanks!
Comment by theht — April 9, 2011 @ 7:39 am |
Very good explanation…clear and simple. I understand.
Comment by Ezani — June 10, 2011 @ 8:55 am |
good explanation …
Comment by narendra — June 19, 2011 @ 9:49 am |
Very clear explanation to have High level idea.
Comment by Siv — June 28, 2011 @ 4:48 pm |
Good Explanation as well very important information gathered.
Comment by Piyush — July 6, 2011 @ 11:16 am |
Well done! However, for optimum cases, using Hibernate directly will be to your advantage. Besides, Hibernate is in itself like a standard in the industry.
Comment by Guest — July 26, 2011 @ 4:00 pm |
Terrible English and spelling. However overall a good summary.
Comment by lokke — September 20, 2011 @ 12:21 pm |
Thi is really helps to understand what is actually JPA.
Comment by rajasheker — October 18, 2011 @ 10:44 pm |
This is simply awesome. I’ve been looking for a precise and short explanation like this. Thanks dude. I’ll be a frequent visitor here
Comment by Ranis MK — October 26, 2011 @ 3:28 pm |
Very good
Comment by Nagoor — October 31, 2011 @ 9:36 am |
Very clear thank you!
I didn’t know about TopLink.
Comment by Dating Ireland — November 13, 2011 @ 9:47 am |
Awesome explaination.
Comment by Satyajeet — December 20, 2011 @ 6:02 pm |
perfect explanation
Comment by Yinka — February 27, 2012 @ 3:49 pm |
good Explanation
Comment by surendra mishra — March 21, 2012 @ 5:52 am |
[...] etc. The underlying mechanism could be changed anytime and the JPA code wouldn’t change.http://elope.wordpress.com/2007/09/06/difference-between-jpa-and-hibernate/ And hibernate 3.0 implements the JPA specification so TopLink and other O/R mapping framework.So [...]
Pingback by The long and short of it all « Tips from a mentor to his protégé — March 21, 2012 @ 9:56 am |
Superb………cleared my doubts, Thx
Comment by syed — March 28, 2012 @ 7:29 pm |
an information that i was looking to differentiate between these 2 (jpa and hibernate), yes it lacks some technical information on differentiation between them …but anyway it helped me out.
Comment by jaggs — April 13, 2012 @ 5:20 am |