unexpected token

I would like to retrieve count of the rows in ScanPT table.
I wrote this query in Hibernate console and got the result 2.

When i use it in my Java code it throws me ERROR org.hibernate.hql.PARSER - line 1:182: unexpected token: q
Can you tell me what iam doing wrong ?

public int checkForPT(long id) throws Exception{
      String sql = "select count(pt) from ScanPT as pt where pt.scanComp.id in " +
                         "(select tasks.id      from Queue as q      inner join q.scanCompany as tasks"+
                         "where q.company.id = ? )";
      List  pnrCount = getHibernateTemplate().find(sql,id);      
      int result = pnrCount.size();      
      return result;
      }
SiddhardhAsked:
Who is Participating?
 
TimCotteeConnect With a Mentor Head of Software ServicesCommented:
Hello Siddhardh,

You concatenate the bits so there is no space between tasks"+"where

public int checkForPT(long id) throws Exception{
      String sql = "select count(pt) from ScanPT as pt where pt.scanComp.id in " +
                         "(select tasks.id      from Queue as q      inner join q.scanCompany as tasks "+
                         "where q.company.id = ? )";
      List  pnrCount = getHibernateTemplate().find(sql,id);      
      int result = pnrCount.size();      
      return result;
      }

Should solve it.

Regards,

TimCottee
0
 
SiddhardhAuthor Commented:
Thanks Much Tim
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.