<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=celal" rel="nofollow">Celal Ziftci</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-5696?redirect=false" rel="nofollow">SPR-5696</a></strong> and commented</p>
<p dir="auto">Currently there are methods that take in "Object[]" for the execution of operations in most of the jdbc.object classes, such as:</p>
<ul dir="auto">
<li>SqlUpdate.update(Object[])</li>
<li>MappingSqlQuery.execute(Object[])</li>
</ul>
<p dir="auto">It would be very beneficial to have a similar method in StoredProcedure as "execute(Object[])".</p>
<p dir="auto">I understand that there is a distinction in terms of update or query, and stored procedures in that stored procs can have a mixture of input and output params. However, this can be handled quite easily by using the already existing metadata provided to construct the StoredProcedure.</p>
<p dir="auto">Below is a sample implementation:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="/**
     * Avoids having to use a Map, hence to duplicate the keys of the map, which are the parameter names already
     * provided while registering the parameters to the {@link StoredProcedure}.
     * 
     * @param values
     *            the values for the &lt;b&gt;input&lt;/b&gt; parameters defined on this stored procedure, in the order of
     *            registration. It is legal for map entries to be null, and this will produce the correct behavior using
     *            a NULL argument to the stored procedure.
     * @return map of output params, keyed by name as in parameter declarations. Output parameters will appear here,
     *         with their values after the stored procedure has been called.
     */
    public Map execute(Object[] values) {
        if (values == null) {
            return execute(Collections.EMPTY_MAP);
        } else {
            List&lt;SqlParameter&gt; params = this.getDeclaredParameters();
            List&lt;SqlParameter&gt; inputParams = new ArrayList&lt;SqlParameter&gt;();
            // filter the input params
            for (SqlParameter sqlParameter : params) {
                if (sqlParameter.isInputValueProvided()) {
                    inputParams.add(sqlParameter);
                }
            }

            // Make sure exactly correct number of arguments are provided
            if (inputParams.size() != values.length) {
                throw new IllegalArgumentException(&quot;There are &quot; + inputParams.size() + &quot; input arguments, but &quot;
                        + values.length + &quot; values are provided&quot;);
            }

            // Create a map, and call existing execute method
            Map&lt;String, Object&gt; valuesToReturn = new HashMap&lt;String, Object&gt;();
            for (int i = 0; i &lt; inputParams.size(); i++) {
                valuesToReturn.put(inputParams.get(i).getName(), values[i]);
            }
            return execute(valuesToReturn);
        }
    }"><pre class="notranslate"><code class="notranslate">/**
     * Avoids having to use a Map, hence to duplicate the keys of the map, which are the parameter names already
     * provided while registering the parameters to the {@link StoredProcedure}.
     * 
     * @param values
     *            the values for the &lt;b&gt;input&lt;/b&gt; parameters defined on this stored procedure, in the order of
     *            registration. It is legal for map entries to be null, and this will produce the correct behavior using
     *            a NULL argument to the stored procedure.
     * @return map of output params, keyed by name as in parameter declarations. Output parameters will appear here,
     *         with their values after the stored procedure has been called.
     */
    public Map execute(Object[] values) {
        if (values == null) {
            return execute(Collections.EMPTY_MAP);
        } else {
            List&lt;SqlParameter&gt; params = this.getDeclaredParameters();
            List&lt;SqlParameter&gt; inputParams = new ArrayList&lt;SqlParameter&gt;();
            // filter the input params
            for (SqlParameter sqlParameter : params) {
                if (sqlParameter.isInputValueProvided()) {
                    inputParams.add(sqlParameter);
                }
            }

            // Make sure exactly correct number of arguments are provided
            if (inputParams.size() != values.length) {
                throw new IllegalArgumentException("There are " + inputParams.size() + " input arguments, but "
                        + values.length + " values are provided");
            }

            // Create a map, and call existing execute method
            Map&lt;String, Object&gt; valuesToReturn = new HashMap&lt;String, Object&gt;();
            for (int i = 0; i &lt; inputParams.size(); i++) {
                valuesToReturn.put(inputParams.get(i).getName(), values[i]);
            }
            return execute(valuesToReturn);
        }
    }
</code></pre></div>
<p dir="auto">The use-case for this is: this avoids having to duplicate the input parameter names twice:</p>
<ul dir="auto">
<li>once during the registration of the input parameter with name to StoredProcedure</li>
<li>second, when we construct the Map for values to pass values to StoredProcedure.execute(Map) method</li>
</ul>
<hr>
<p dir="auto"><strong>Affects:</strong> 3.0 M1</p>
<p dir="auto"><strong>Referenced from:</strong> commits <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/spring-projects/spring-framework/commit/7c053127ddc4cbfdf0aef8778029d087cd11d808/hovercard" href="https://github.com/spring-projects/spring-framework/commit/7c053127ddc4cbfdf0aef8778029d087cd11d808"><tt>7c05312</tt></a></p>
<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=grzegorzborkowski" rel="nofollow">Grzegorz Borkowski</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-5327?redirect=false" rel="nofollow">SPR-5327</a></strong> and commented</p>
<p dir="auto">Currently Spring Framework depends on Commons-Logging. All of us know that for long time Commons-Logging has very bad reputation and is the source of many problems, bug, memory leaks etc.<br>
The SLF4j is the newer implementation of similar idea, and many people claim it works much better than Commons-Logging. It contain even some adapter for Commons-Logging users, allowing for gradual transition. Perhaps with Spring 3, along with migration to Java 5, is the best time to migrate also to SLF4J and remove dependency on Commons-Logging?<br>
In fact, you can probably do it somehow automatically, writing the script that will replace in all java files the imports and logger types.</p>
<hr>
<p dir="auto"><strong>Affects:</strong> 3.0 M4</p>
<p dir="auto"><strong>Attachments:</strong></p>
<ul dir="auto">
<li><a href="https://jira.spring.io/secure/attachment/15468/SPR-5327.patch" rel="nofollow">SPR-5327.patch</a> (<em>511.88 kB</em>)</li>
</ul>
<p dir="auto"><strong>Issue Links:</strong></p>
<ul dir="auto">
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398111146" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/12774" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/12774/hovercard" href="https://github.com/spring-projects/spring-framework/issues/12774">#12774</a> Revisit subsystem-oriented logging</li>
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398195939" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/19081" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/19081/hovercard" href="https://github.com/spring-projects/spring-framework/issues/19081">#19081</a> Revisit Commons Logging vs java.util.logging vs SLF4J vs Log4j 2</li>
</ul>
<p dir="auto"><strong>Referenced from:</strong> commits <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/spring-projects/spring-framework/commit/f4763a801fe0a8f57aafeb2f9fb97d0d9fad43a5/hovercard" href="https://github.com/spring-projects/spring-framework/commit/f4763a801fe0a8f57aafeb2f9fb97d0d9fad43a5"><tt>f4763a8</tt></a>, <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/spring-projects/spring-framework/commit/1a06b6a0ab2f7744324de0e8dbdb167c3c83e126/hovercard" href="https://github.com/spring-projects/spring-framework/commit/1a06b6a0ab2f7744324de0e8dbdb167c3c83e126"><tt>1a06b6a</tt></a>, <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/spring-projects/spring-framework/commit/ad3fa505f33d3533f226ad32ddb833b757343400/hovercard" href="https://github.com/spring-projects/spring-framework/commit/ad3fa505f33d3533f226ad32ddb833b757343400"><tt>ad3fa50</tt></a>, <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/spring-projects/spring-framework/commit/604a9f077d5081865a7189124a17a840d2a83d42/hovercard" href="https://github.com/spring-projects/spring-framework/commit/604a9f077d5081865a7189124a17a840d2a83d42"><tt>604a9f0</tt></a>, <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/spring-projects/spring-framework/commit/b7e37ddb072b0b0a57659761e5fceddb3a854bc0/hovercard" href="https://github.com/spring-projects/spring-framework/commit/b7e37ddb072b0b0a57659761e5fceddb3a854bc0"><tt>b7e37dd</tt></a>, <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/spring-projects/spring-framework/commit/1202f67cc8afbdc7d49a43ea8a86a549fbfbb37a/hovercard" href="https://github.com/spring-projects/spring-framework/commit/1202f67cc8afbdc7d49a43ea8a86a549fbfbb37a"><tt>1202f67</tt></a>, <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/spring-projects/spring-framework/commit/0400ccc11fa19b29c4b2a5e2b0f10b85679feed6/hovercard" href="https://github.com/spring-projects/spring-framework/commit/0400ccc11fa19b29c4b2a5e2b0f10b85679feed6"><tt>0400ccc</tt></a></p>
<p dir="auto">20 votes, 13 watchers</p>