title: Hibernate QueryException: 'Not all named parameters have been set' - with native query containing ::int
body: <p>in our current project we need a query of the long-matching-prefix type but the column was oddly enough defined as <em>bigint</em>. We came up with the solution in the snippet below, where we want to find the longest number in column <em>dc</em> that matches the parameter <em>?2</em> and <em>?3</em>, and <em>?1</em> date is between the 2 date columns.</p>
  
  <p>Here are the relevant dependencies:</p>
  
  <ul>
  <li>Postresql 8.4</li>
  <li>Hibernate 3.6.10</li>
  <li>Hibernate JPA 1.0.1</li>
  <li>Spring 3.2.1</li>
  </ul>
  
  <p>Here is the source:</p>
  
  <pre><code>...
  String query_string = "SELECT * FROM numberlist WHERE " +
              "?1 BETWEEN init_date AND COALESCE(end_date,'2999-12-31') " +
              "AND dc IN " +
              "(select ?2/(10^i)::int8 from generate_series(0,floor(log(?3))::int) i) " +
              "ORDER BY dc DESC LIMIT 1";
  
  Query query = emf.createEntityManager().createNativeQuery(query_string, MyNumber.class);
      query.setParameter(1, valid_date);
      query.setParameter(2, num);
      query.setParameter(3, num);
  
  MyNumber result = (MyNumber)query.getSingleResult();
  ...
  </code></pre>
  
  <p>We are getting the following exception:</p>
  
  <pre><code>Caused by: org.hibernate.QueryException: Not all named parameters have been set: [:int8, :int]
  </code></pre>
  
  <p>We think the problem is Hibernate taking <em>:int</em> and <em>:int8</em> as parameters but cannot find the solution.</p>
  
  <p>Thank you for your help.</p>