Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-10499

camel-sql - error in multiple dynamic IN replacement

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.18.0
    • Fix Version/s: 2.17.6, 2.18.1, 2.19.0
    • Component/s: camel-sql
    • Labels:
      None
    • Estimated Complexity:
      Unknown

      Description

      Having this sql

      select *
      from projects
      where project in (:#in:names)
      and license in (:#in:licenses)
      order by id
      

      and send as following

      Map<String, Object> headers = new HashMap<>();
      headers.put("names", new String[]{"Camel", "AMQ"});
      headers.put("licenses", new String[]{"ASF", "XXX", "YYY"});
      template.requestBodyAndHeaders("direct:query", "Hi there!", headers);
      

      causes parameter mismatch

      Caused by: java.sql.SQLException: Number of parameters mismatch. Expected: 4, was: 5
              at org.apache.camel.component.sql.DefaultSqlPrepareStatementStrategy.populateStatement(DefaultSqlPrepareStatementStrategy.java:152) ~[classes/:?]
              at org.apache.camel.component.sql.SqlProducer$2.doInPreparedStatement(SqlProducer.java:146) ~[classes/:?]
              at org.apache.camel.component.sql.SqlProducer$2.doInPreparedStatement(SqlProducer.java:116) ~[classes/:?]
              at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:633) ~[spring-jdbc-4.3.4.RELEASE.jar:4.3.4.RELEASE]
              ... 51 more
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                igarashitm Tomohisa Igarashi
                Reporter:
                igarashitm Tomohisa Igarashi
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: