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 |