This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Difference between HQL and DetachedCriteria

 
jagrutkumar dalwadi
Ranch Hand
Posts: 83
Hibernate Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Friends,
I m using Hibernate 3.0. I am little new to hibernate. For getting the data from database, i am using DetachedCriteria and also HQL(Hibernate Query Language). Difference between HQL and DetachedCriteria.

I want to know that in which situation i use DetachedCriteria
and in which situation i use HQL?

and also tell what is the difference between them and drawbacks over each other?

Please try to help my problem.

Hoping for a very good reply.

Regards,
Jagrut
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HQL allows you to query the database based on the relationships between your objects, in a way that mimics SQL, but in a very object-oriented manner.

A criteria query uses the Hibernate Criteria API to programatically create queries based on your objects, and various classes such as restriction and example.

Here's an HQL Example from my Hibernate Query Language Tutorial:





Here's a Hibernate Criteria Example from my tutorial on using the Hibernate Criteria API:




-Cameron McKenzie
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic