title: Spring Dao says bad SQL grammar - syntax error
body: <blockquote>
    <p>org.springframework.jdbc.BadSqlGrammarException:
    PreparedStatementCallback; bad SQL grammar     [DELETE
    model_state_history FROM model_state_history INNER JOIN model ON
    model_state_history.model_id = model.id WHERE model.package_id = ?];
    nested exception is org.h2.jdbc.JdbcSQLException: Syntax error in SQL
    statement "DELETE model_state_history FROM[*] model_state_history
    INNER JOIN model ON model_state_history.model_ID = model.ID WHERE
    model.PACKAGE_ID = ? "; SQL statement:</p>
  </blockquote>
  
  <p>And it throws the above in the output. For my eyes, I don't see a syntax error. I am using MySQL database. Is there anything which is obviously wrong in SQL syntax above?</p>
  
  <p>Using the DELETE FROM syntax gives the syntax error too.</p>
  
  <blockquote>
    <p>org.springframework.jdbc.BadSqlGrammarException:
    PreparedStatementCallback; bad SQL grammar [DELETE FROM
    model_state_history INNER JOIN model ON model_state_history.model_id =
    model.id WHERE model.package_id = ?]; nested exception is
    org.h2.jdbc.JdbcSQLException: Syntax error in SQL statement "DELETE
    FROM model_STATE_HISTORY INNER[*] JOIN model ON
    model_STATE_HISTORY.model_ID = model.ID WHERE model.PACKAGE_ID = ? ";
    SQL statement: DELETE FROM model_state_history INNER JOIN model ON
    model_state_history.model_id = model.id WHERE model.package_id = ?
    [42000-176]</p>
  </blockquote>
  
  <p>And this is the piece of code that is being run</p>
  
  <pre><code>  @Transactional
    private int deleteAllModels(Long packageId) throws DataAccessException {
      return new NamedParameterJdbcTemplate(dataSource).update(
          "DELETE FROM model_state_history INNER JOIN model ON model_state_history.version_id = model.id WHERE model.package_id = :package_id",
          ImmutableMap.of("package_id", packageId));
  </code></pre>