Michael
Michael

Reputation: 33297

How to order a Result by Alphabet in Hibernate HQL?

I want to order my result by name in alphabetic order. I tested this:

select u.name from User as u 
order by u.name desc

This did not work. How can I sort alphabetically?

Upvotes: 0

Views: 2320

Answers (3)

Mukesh S
Mukesh S

Reputation: 2876

This query is correct, there is nothing wrong in it:

select u.name from User as u order by u.name desc

But there is problem in this query:

from User u select u.name order by u.name

The syntax does not seems correct. For more queries you can see: org hibernate

Upvotes: 1

James Kleeh
James Kleeh

Reputation: 12228

This works for me in a console:

User.executeQuery("Select u.name from User u order by u.name desc")

Upvotes: 1

tkt986
tkt986

Reputation: 1028

If you are looking for a Hibernate Query Language, try this:

from User u select u.name order by u.name

Upvotes: 2

Related Questions