• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

when to use HQL and when to use Criteria?

 
Hemant Agarwal
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When to use HQL and When to use creteria?
i) I mean is there any particular condition where I can use only creteria and
not HQL or vice versa?
ii) In which condition it is better to use creteria or vice versa?
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Personal preference is about all there is to differentiate. Criteria have the advantage of not being open to syntax errors, HQL is (to my mind) easier to understand, since it looks pretty much like SQL. I suppose dynamic, adhoc queries ar easier to implement in HQL too.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic