Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • salvin francis
  • fred rosenberger

Difference between HQL and DetachedCriteria

Ranch Hand
Posts: 83
Hibernate Spring Java
  • 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.

author and cow tipper
Posts: 5000
Hibernate Spring Tomcat Server
  • 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
Do you want ants? Because that's how you get ants. And a tiny ads:
Devious Experiments for a Truly Passive Greenhouse!
    Bookmark Topic Watch Topic
  • New Topic