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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

TimCotteeHead 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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
SiddhardhAuthor Commented:
Thanks Much Tim
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Query Syntax

From novice to tech pro — start learning today.