I am quiet new to Hibernate and JPA. I started hibernate before but left it because of other demands.
I am currently using JPA and Hibernate as a persistance provider integrated with Spring. I have a question,
that when we write query statements, can we directly write HQL in JPA. Will that work or we have to write
queries specific to JPA.
You can consider JPA query language as a sub set of HQL. HQL supports all JPA QL features and provides additional ( vendor specific) extensions like Criterion, Query By Examples...etc.
If you use JPA queries , your application will be less coupled with hibernate.
Joined: Oct 13, 2009
Thanks for your quick turn-around.
On note of that, i have another question. What will be best practice, what query language to use, when you are using
JPA but persistance provider as Hibernate? Will HQL be the appropriate choice or JPA own query language?
Joined: Aug 09, 2005
I prefer JPA queries as much as possible. But if your application is using hibernate implementation and if there is no plans in future to move off from hibernate, you can also use Hibernate Queries.