title: JOOQ SQL given 1 parameters but expected 0
body: <p>I'm trying to figure out how to use JOOQ with NamedParameterJdbcTemplate. I have successfully created other queries, but I'm stuck at creating a query containing the WHERE clause. When I try to run the method below, I get the error <strong>org.springframework.dao.InvalidDataAccessApiUsageException: SQL [select "first_name" from "customer" where "id" = cast(? as integer)]: given 1 parameters but expected 0</strong></p>
  
  <p>I get the same error when I try to use only integers in equals(), like... .where(fieldByName("id").equal(1001), same error and .where(fieldByName("id").equal(id), same error.</p>
  
  <p>If I remove the WHERE clause, the query itself seems to work fine.</p>
  
  <p>What am I doing wrong here? It seems to me that the SQL syntax is correct. It's probably me being stupid, but I really can't find what's wrong here. Please help!</p>
  
  <pre><code>public String getCustomerFirstName(int id) {
      Query query = create.select(fieldByName("first_name"))
                      .from(tableByName("customer"))
                      .where(fieldByName("id").equal(param("id", id)));
      Param param = query.getParam("id");
      SqlParameterSource namedParameters = new MapSqlParameterSource(param.getName(), id);
      return this.getNamedParameterJdbcTemplate().queryForObject(query.getSQL(), namedParameters, String.class);
  }
  </code></pre>