File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

When we choose SQL,HQL and Criteria API of hibernate?

 
Murugesan Pitchandi
Greenhorn
Posts: 8
Hibernate Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have java application which is going use hibernate. My doubt is when we choose SQL,HQL and Criteria API of hibernate?
 
Bill Gorder
Bartender
Posts: 1682
7
Android IntelliJ IDE Linux Mac OS X Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Short answer which gives some general guidelines but not necessarily right for every scenario:

- HQL - use this (preferably named) for most queries. They are easy to read and write.
- Criteria - use this for dynamic queries
- SQL - use this where the other 2 are not a good fit or you want to do something Hibernate either is not designed for, or does not do well. Often times this may be using straight JDBC for some stored procedure work, or batch jobs for example. While Hibernate can do these things it is not always the best choice.
 
Murugesan Pitchandi
Greenhorn
Posts: 8
Hibernate Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Bill for your reply.

SQL - use this where the other 2 are not a good fit or you want to do something Hibernate either is not designed for, or does not do well. Often times this may be using straight JDBC for some stored procedure work, or batch jobs for example. While Hibernate can do these things it is not always the best choice.

You mean to say, in case your application having stored procedure/batch process then HQL and Criteria API of hibernate work and it will support by SQL only. Please correct me if i am wrong.

Thanks and Regards,
Murugesab
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic