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
"Knowing is not enough, you must apply... Willing is not enough, you must do."
--Bruce Lee
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
Joined: Mar 04, 2008
Posts: 114
posted
0
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 ]
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.
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 ?
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
Joined: Dec 13, 2009
Posts: 2
posted
0
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
Joined: Dec 14, 2009
Posts: 125
posted
0
Thanks Gaurav, i will try to get back your answer.
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.
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).