title: Getting error that unexpected token: ON near line 1, column 135
body: <p>I am new to hibernate and trying to run query in hibernate but i am getting the exception that </p>
  
  <pre><code>unexpected token: ON near line 1, column 135 [SELECT A.comp_id.appRefNo ....
  </code></pre>
  
  <p>Here is the code</p>
  
  <pre><code>StringBuffer query = new StringBuffer("SELECT A.comp_id.appRefNo, 
      A.comp_id.custId from ");
  
  query.append(LosaCustContactZ.class.getName());
  
  query.append(" A INNER JOIN " + LosaCust.class.getName() + " B 
      ON ( B.comp_id.appRefNo = A.comp_id.appRefNo AND " + 
      "B.comp_id.custId = A.comp_id.custId) INNER JOIN " + LosaApp.class.getName() + " C 
      ON " + "(B.comp_id.appRefNo = A.comp_id.appRefNo) ");
  
  query.append("WHERE C.comp_id.appRefNo != ?" + " AND C.appDt &gt;= ? AND 
      A.contactT = 'PHONE'" ); 
  
  if (StringUtils.isNotEmpty(phoneNums)) {
      query.append(" AND A.contact IN(" + phoneNums + ")");
  }
  
  List&lt;LosaCustContactZ&gt; resultList = null;
  try {
      resultList = getHibernateTemplate().find(query.toString(), 
             new Object[] { appRefNo, appDate });
  } catch (Exception e) {
      String message = e.getMessage();
  System.out.println();
  }
  return resultList;
  </code></pre>
  
  <p>what i am doing wrong ?</p>
  
  <p>Thanks</p>