title: Hibernate Parameter value [568903] did not match expected type [java.lang.Long]
body: <p>I am using Hibernate 4 and I have a filter in JSF page to get search results. During execution of search I am getting the following exception </p>
  
  <blockquote>
    <p>java.lang.IllegalArgumentException: Parameter value [568903] did not match 
        expected type [java.lang.Long]
            at org.hibernate.ejb.AbstractQueryImpl.validateParameterBinding(AbstractQueryImpl.java:370)
            at org.hibernate.ejb.AbstractQueryImpl.registerParameterBinding(AbstractQueryImpl.java:343)
            at org.hibernate.ejb.QueryImpl.setParameter(QueryImpl.java:370)
            at org.hibernate.ejb.QueryImpl.setParameter(QueryImpl.java:323)</p>
  </blockquote>
  
  <p>Below is my code snippet, how can I fix this issue?</p>
  
  <pre><code>private Long projectNo; 
  
  public Long getProjectNo() {
      return projectNo;
  }
  
  public void setProjectNo(Long projectNo) {
      this.projectNo = projectNo;
  }
  </code></pre>
  
  <p>And in DAO class I have the following</p>
  
  <pre><code>String projectNo = filters.get("projectNo");
  List&lt;Predicate&gt; criteria = new ArrayList&lt;Predicate&gt;();
      if (projectNo!= null) {
      ParameterExpression&lt;String&gt; pexp = cb.parameter(String.class, "projectNo");             
      Predicate predicate = cb.equal(emp.get(Project_.projectNo), pexp);
      criteria.add(predicate);
  }
  TypedQuery&lt;Project&gt; q = entityManager.createQuery(c);
  TypedQuery&lt;Long&gt; countquery = entityManager.createQuery(countQ);
  q.setParameter("projectNo", projectNo); // error in this line
  countquery.setParameter("projectNo", projectNo);
  </code></pre>
  
  <p><strong>Edit 1</strong></p>
  
  <pre><code>public void getProjects(ProjectQueryData data) { 
  </code></pre>
  
  <p>and in <code>ProjectQueryData</code> class, I have the following as constructor</p>
  
  <pre><code>public ProjectQueryData (int start, int end, String field,
              QuerySortOrder order, Map&lt;String, String&gt; filters) {
  </code></pre>