You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Robert Huffman (JIRA)" <ji...@apache.org> on 2016/05/21 21:30:12 UTC

[jira] [Updated] (DBUTILS-129) Add methods to QueryRunner that take Collections or Iterables

     [ https://issues.apache.org/jira/browse/DBUTILS-129?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Robert Huffman updated DBUTILS-129:
-----------------------------------
    Attachment: dbutils-129.patch

This patch adds methods to QueryRunner that take Collections rather than arrays of parameters. The existing methods that take arrays were re-implemented in terms of the new methods. A new test class was added to test the new methods.

Because the deprecated methods in QueryRunner were touched, I also added another test class to test them. Previously they were untested, I believe.

> Add methods to QueryRunner that take Collections or Iterables
> -------------------------------------------------------------
>
>                 Key: DBUTILS-129
>                 URL: https://issues.apache.org/jira/browse/DBUTILS-129
>             Project: Commons DbUtils
>          Issue Type: Improvement
>            Reporter: Robert Huffman
>         Attachments: dbutils-129.patch
>
>
> If a prepared statement is built dynamically, with a variable number of parameters, and parameters are in a Collection of some sort instead of an array, usage QueryRunner requires that the collection be converted to an array first. This means the parameters are iterated twice: once to convert to an array and once again in QueryRunner.fillStatement.
> It should be straightforward to add insert, execute, and update methods that take Collections. The methods that take arrays can then be re-implemented using the inexpensive Arrays.asList and invoking the new methods.
> It would probably be preferable to take Iterables instead of Collections. However, the current implementation of AbstractQueryRunner.fillStatement requires up-front knowledge of the size of the parameter set passed to it, and that is not easily obtained from the Iterable interface. To allow iterables that method would have to be refactored.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)