title: Postgresql- Hibernate Query Syntax exception : org.hibernate.hql.ast.QuerySyntaxException: unexpected token at near
body: <p>I am using Postgresql with hibernate. <code>now()</code> is working fine but <code>now()</code> at time zone UTC is throwing an error. </p>
  
  <p>Version: Postgresql9.5.
  The same sql query is working fine in pgAdmin.</p>
  
  <pre><code>String sql = "SELECT a FROM XspJobRequest a " +
              "WHERE a.xspJobTypeId = :xspJobTypeId " +
              "AND a.xspJobStatusId = :xspJobStatusId " +
              "AND a.nextAttemptTs &lt; (now() at time zone 'utc') " +
              " ORDER BY a.insertTs";
      try
      {
          Query query = entityManager.createQuery(sql);
          query.setMaxResults(limitReturnCount);
          query.setParameter("xspJobTypeId", jobType.getId());
          query.setParameter("xspJobStatusId", XspJobStatusEnum.eNew.getId());
          List&lt;XspJobRequest&gt; retval = query.getResultList();
  
          if (!alreadyActive)
          {
              et.commit();
          }
          return retval;
      }
  </code></pre>
  
  <blockquote>
    <p>java.lang.IllegalArgumentException:
    org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token:
    at near line 1, column 167 [SELECT a FROM
    com.hp.jampub.db.entity.XspJobRequest a WHERE a.xspJobTypeId =
    :xspJobTypeId AND a.xspJobStatusId = :xspJobStatusId AND
    a.nextAttemptTs &lt; (select now() at time zone 'utc')  ORDER BY
    a.insertTs]</p>
  </blockquote>