title: How to get parameterized query with iBatis-Spring
body: <p>I'm working on an application with spring-ibatis integration in which I have to log some of the query performed. So what I'd like to do, is basically getting the SQL from the ibatis mapped statements in the XML config file and then add somehow the parameters. I've been able to get the query with this lines of code:</p>
  
  <pre><code>MappedStatement ms = (MappedStatement) ((SqlMapClientImpl) sqlMapClient)
      .getDelegate().getMappedStatement(queryId);
  
  ms.setParameterClass(HashMap.class);
  RequestScope scope = new RequestScope();
  scope.setStatement(ms);
  
  String sql = ((DynamicSql) ms.getSql()).getSql(scope, params);
  </code></pre>
  
  <p>So with the first row I get the MappedStatement and with the last one I get the raw query. The problem is that even if I'm passing to it the object with the query parameters, the SQL still has the parameters placeholders '?' (in the XML query they are named parameters, not positionals).</p>
  
  <p>I have tried to set the <code>parameterClass</code> field instead of the <code>parameterMap</code> as suggested <a href="https://ibatis.apache.org/docs/dotnet/datamapper/ch03s04.html" rel="nofollow noreferrer">here</a> but with no success. I'm not sure on how to work with the inline parameters.</p>
  
  <p>I'm using <code>ibatis-sqlmap 2.3.0</code> and <code>spring-ibatis 2.0.8</code>.</p>
  
  <p>As you have probably noticed I have little to no knowledge of iBatis. Also, please I know that this is dirty and that I'm using classes that I'm not supposed to, no need to point that out.</p>
  
  <p>Thank you for the help.</p>