Puneet Pandey
Puneet Pandey

Reputation: 960

Group by with Order in MySQL with Hibernate

I am running MySQL query (not HQL) with Hibernate. I am trying to use Group by desc and it gives me exception -

unexpected token: desc near line 1, column 340

The same query, however, works when I run it in mySQL command line.

Upvotes: 0

Views: 80

Answers (1)

Rahul
Rahul

Reputation: 77906

That's because desc is a reserve word and should be escaped using backtique like below. Better yet, don't use reserve word at all (OR) if you had to then try using some other word along with it like desc_HQL

 Group by  `desc`

Upvotes: 1

Related Questions