[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 838
  • Last Modified:

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;
      }
0
Siddhardh
Asked:
Siddhardh
1 Solution
 
TimCotteeCommented:
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

Featured Post

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now