• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

unexpected token: group

 
diana yusof
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could anybody answer me how to make this code run.

String sql = "select MONTH(CC.createddateTs) as months , "+

"(SELECT COUNT(CC1.communicationtypeTx) from Customercommunication as CC1 "+
" where CC1.communicationtypeTx = 'Complaint' and MONTH(CC1.createddateTs)= MONTH(CC.createddateTs) "+
" group by MONTH(CC1.createddateTs) ) as complaint," +

"(SELECT COUNT(CC2.communicationtypeTx) from Customercommunication as CC2 "+
" where CC2.communicationtypeTx = 'Enquiry' and MONTH(CC2.createddateTs)= MONTH(CC.createddateTs) "+
" group by MONTH(CC2.createddateTs) ) as Enquiry "+

"from Customercommunication as CC where YEAR((CC.createddateTs) = 2008 group by MONTH(CC.createddateTs) "+
"order by MONTH(CC.createddateTs) ASC";

Query query = mSession.createQuery(sql);

when i run this code i get this error:
ERROR [org.hibernate.hql.PARSER] - <line 1:698: unexpected token: group>
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch.

I'd say that either there's a comma missing after "as Enquiry", and/or a SELECT clause before "from Customercommunication".

Since this has nothing to do with the SCEA certification -which this forum is about- I'll move it to ORM forum where Hibernate is discussed.
 
Edvins Reisons
Ranch Hand
Posts: 364
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looks like an SQL query got into a method that expected HQL.
See here how to use SQL queries in Hibernate.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic