public BoundSql getBoundSql(Object parameterObject) {
    Map<String, Object> bindings = createBindings(parameterObject, configuration);
    VelocityContext context = new VelocityContext(bindings);
    StringWriter sw = new StringWriter();
    script.merge(context, sw);
    VelocitySqlSourceBuilder sqlSourceParser = new VelocitySqlSourceBuilder(configuration);
    Class<?> parameterType = parameterObject == null ? Object.class : parameterObject.getClass();
    SqlSource sqlSource = sqlSourceParser.parse(sw.toString(), parameterType);
    BoundSql boundSql = sqlSource.getBoundSql(parameterObject);
    for (Map.Entry<String, Object> entry : bindings.entrySet()) {
      boundSql.setAdditionalParameter(entry.getKey(), entry.getValue());
    }
    return boundSql;

  }
Just a test case. Not a real Velocity implementation.
src/test/java/org/apache/ibatis/submitted/language/VelocitySqlSource.java