This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes JPA Query and HQL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "JPA Query and HQL" Watch "JPA Query and HQL" New topic
Author

JPA Query and HQL

Prithvi Sehgal
Ranch Hand

Joined: Oct 13, 2009
Posts: 774
Hello All,

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.

Please help,

Prithvi,
My Blog, Follow me on Twitter,Scjp Tips, When you score low in mocks, Generics,Scjp Notes, JavaStudyGroup
Reddy Prashanth
Ranch Hand

Joined: Aug 09, 2005
Posts: 61
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.
Prithvi Sehgal
Ranch Hand

Joined: Oct 13, 2009
Posts: 774
Hello,

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?

Best Regards,
Reddy Prashanth
Ranch Hand

Joined: Aug 09, 2005
Posts: 61
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JPA Query and HQL
 
Similar Threads
EJB-Ql vs HQL
Use custom query on JPA
Stored Procedure inside HQL query?
Difference between Hibernate and JPA
EntityManager Query Language