title: JdbcTemplate's update method does not update without PreparedStatementCreator
body: <p>I have the following table</p>
  
  <pre><code>CREATE TABLE user_use_case_control (
  id integer GENERATED BY DEFAULT AS IDENTITY (START WITH 10, INCREMENT BY 1) not null,
  name varchar(20) not null,
  start_date timestamp not null,
  end_date timestamp null,
  duration timestamp null,
  status varchar(20) null,
  user_id varchar(20) not null ); 
  </code></pre>
  
  <p>I am working with Spring Framework 4.0.5, with <strong>JdbcTemplate</strong>,  and I have the following insertion method (part of the method)</p>
  
  <p><strong>Alpha</strong></p>
  
  <pre><code>this.jdbcTemplate.update(
  
          new PreparedStatementCreator()  {
  
              @Override
              public PreparedStatement createPreparedStatement(Connection connection) throws SQLException {
  
                  PreparedStatement ps = connection.prepareStatement(sql,  
                  Statement.RETURN_GENERATED_KEYS);
  
                  ps.setString(1, userControl.getName());
                  ps.setTimestamp(2, new Timestamp( userControl.getStartDate().getTime() ));
                  ps.setTimestamp(3, new Timestamp( userControl.getEndDate().getTime() ));
                  ps.setTimestamp(4, new Timestamp( userControl.getDuration().getTime() ));
                  ps.setString(5, userControl.getStatus());
                  ps.setString(6, userControl.getUserId());
  
             return ps;
            }
      }, keyHolder);
  </code></pre>
  
  <p>Observe: </p>
  
  <ul>
  <li>I am using <code>PreparedStatementCreator</code> to get the generated key.</li>
  <li>I am using <code>ps.setTimestamp</code> and <code>new Timestamp</code></li>
  </ul>
  
  <p>The insertion method works fine.</p>
  
  <p>The problem is for the update. </p>
  
  <p>I have the following:</p>
  
  <p><strong>Beta</strong></p>
  
  <pre><code>@Override
  public UserControl update(UserControl userControl) {
  
      logger.info("UserControlJdbcRepository - update {}", userControl.toString());
  
      String sql = "UPDATE user_use_case_control uucc " +
                   "SET uucc.name=?, uucc.start_date=?, uucc.end_date=?, uucc.duration=?, uucc.status=? " +
                   "WHERE uucc.id=?";
  
  
      int result = this.jdbcTemplate.update(sql,
                      userControl.getName(),
                      new Timestamp( userControl.getStartDate().getTime() ),
                      new Timestamp( userControl.getEndDate().getTime() ),
                      new Timestamp( userControl.getDuration().getTime() ),
                      userControl.getStatus(),
                      userControl.getUserId());
  
      logger.info("result {}", result);
  …
  </code></pre>
  
  <ul>
  <li>with logger I can see the object and all their variables are not null</li>
  </ul>
  
  <p>The <strong>problem</strong> is: the <code>jdbcTemplate.update</code> <strong>does not</strong> update nothing! </p>
  
  <p>Same situation if I use</p>
  
  <pre><code>int result = this.jdbcTemplate.update(sql,
                   userControl.getName(),
                   userControl.getStartDate(),
                   userControl.getEndDate(),
                   userControl.getDuration(),
                   userControl.getStatus(),
                   userControl.getUserId());
  </code></pre>
  
  <p>If I do a debug and logger with DEBUG level, I can see the following: </p>
  
  <pre><code>Executing prepared SQL update
  Executing prepared SQL statement [UPDATE user_use_case_control uucc SET uucc.name=?, uucc.start_date=?, uucc.end_date=?, uucc.duration=?, uucc.status=? WHERE uucc.id=?]
  SQL update affected 0 rows
  SQLWarning ignored: SQL state '02000', error code '-1100', message [no data]
  </code></pre>
  
  <p>I dont understand why happens this. </p>
  
  <p>If the logger has INFO level none error appears, I mean some exception does not arise.</p>
  
  <p>If I change the method with the following:</p>
  
  <p><strong>Omicron</strong></p>
  
  <pre><code>int result = this.jdbcTemplate.update(
  
          new PreparedStatementCreator()  {
  
              @Override
              public PreparedStatement createPreparedStatement(Connection connection) throws SQLException {
  
                  PreparedStatement ps = connection.prepareStatement(sql);
  
                  ps.setString(1, userControl.getName());
                  ps.setTimestamp(2, new Timestamp( userControl.getStartDate().getTime() ));
                  ps.setTimestamp(3, new Timestamp( userControl.getEndDate().getTime() ));
                  ps.setTimestamp(4, new Timestamp( userControl.getDuration().getTime() ));
                  ps.setString(5, userControl.getStatus());
                  ps.setInt(6, userControl.getId());
  
                  return ps;
              }
  
          });
  
  logger.info("result {}", result);
  </code></pre>
  
  <p>Just then: It works totally fine.</p>
  
  <p>Observe:</p>
  
  <ul>
  <li>Alpha, Beta and Omicron uses <code>ps.setTimestamp</code> and <code>new Timestamp</code></li>
  </ul>
  
  <p>Questions:</p>
  
  <ol>
  <li>Why <strong>Beta</strong> fails? (message [no data])</li>
  <li>Why only works the updating with <code>PreparedStatementCreator</code>?</li>
  </ol>
  
  <p><strong>Note:</strong> I have other Repositories and the <code>update</code> methods based on <strong>Beta</strong>, working without <code>PreparedStatementCreator</code>, work fine. </p>
  
  <p>Just to highlight about the other repositories:</p>
  
  <ul>
  <li>some of them have no a <code>timestamp</code> field, just have <code>date</code> in the db table schema.</li>
  <li>some of them neither have a <code>timestamp</code> field nor a <code>date</code> field in the db table schema.</li>
  </ul>
  
  <p>Therefore this weird behaviour only appears for <strong>update</strong> when the <code>timestamp</code> field is involved.</p>
  
  <p>Thanks in advance.</p>