Hello,
(first of all, sorry about my
english)
I started using HQL Query. From my point of view, if you have an idea about SQL it's easier to devolop some
applications than using Criteria. However, I found some cases where Criteria makes life easier.
For instance, If you want to add restrictions to a query dinamically. I think it's easier to use Criteria. Imagine that you should create a query which depends on the restrictions a user selected on your front-end.
Imaging user want to obtain information using restriction 1:
Code:
createCriteria c
If (user want restriction 1)
c.add(Restrictions 1)
If (user want restriction 2)
c.add(Restrictions 2)
c.list
When using HQL you have to code the restriction handly, and you have to control several aspect tha Criteria do
Code:
query=" where "
If(user want restriction 1)
query = query + "restriction 1 ..."
If(user want restriction 2)
query = query + "restriction 2 ..."
createQuery q ("select * from "+query).list
I hope help you :-S