[jira] [Created] (DBUTILS-97) Add an AbstractResultSetHandler implementation in order to reduce the

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

[jira] [Created] (DBUTILS-97) Add an AbstractResultSetHandler implementation in order to reduce the

ASF GitHub Bot (Jira)
Simone Tripodi created DBUTILS-97:
-------------------------------------

             Summary: Add an AbstractResultSetHandler implementation in order to reduce the
                 Key: DBUTILS-97
                 URL: https://issues.apache.org/jira/browse/DBUTILS-97
             Project: Commons DbUtils
          Issue Type: New Feature
    Affects Versions: 1.6
            Reporter: Simone Tripodi
            Assignee: Simone Tripodi
             Fix For: 1.6


According to the DRY principle (Don't Repeat Yourself), repeating {{resultSet}} variable inside the {{ResultSetHandler#handle(ResultSet)}} over and over for each iteration can get a little tedious.
It would be helpful adding a support class, named {{AbstractResultSetHandler}}, which implicitly gives users access to {{ResultSet}}'s methods. _For example_, we could extend {{AbstractResultSetHandler}} and rewrite the mapping below:

{code}
new ResultSetHandler<Collection<Map<String, Object>>> {

    @Override
    public Collection<Map<String, Object>> handle(ResultSet rs) throws SQLException {
        Collection<Map<String, Object>> result = new LinkedList<Map<String, Object>>();

        while (rs.next()) {
            Map<String, Object> current = new HashMap<String, Object>();
            for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++) {
                current.put(rs.getMetaData().getColumnName(i), rs.getObject(i));
            }

            result.add(current);
        }

        return result;
    }

}
{code}

as:

{code}
new AbstractResultSetHandler<Collection<Map<String, Object>>> {

    @Override
    protected Collection<Map<String, Object>> handle() throws SQLException {
        Collection<Map<String, Object>> result = new LinkedList<Map<String, Object>>();

        while (next()) {
            Map<String, Object> current = new HashMap<String, Object>();
            for (int i = 1; i <= getMetaData().getColumnCount(); i++) {
                current.put(getMetaData().getColumnName(i), getObject(i));
            }

            result.add(current);
        }

        return result;
    }

}
{code}


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       
Reply | Threaded
Open this post in threaded view
|

[jira] [Updated] (DBUTILS-97) Add an AbstractResultSetHandler implementation in order to reduce redundant 'resultSet' variable invocation

ASF GitHub Bot (Jira)

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

Simone Tripodi updated DBUTILS-97:
----------------------------------

    Summary: Add an AbstractResultSetHandler implementation in order to reduce redundant 'resultSet' variable invocation  (was: Add an AbstractResultSetHandler implementation in order to reduce the )
   

> Add an AbstractResultSetHandler implementation in order to reduce redundant 'resultSet' variable invocation
> -----------------------------------------------------------------------------------------------------------
>
>                 Key: DBUTILS-97
>                 URL: https://issues.apache.org/jira/browse/DBUTILS-97
>             Project: Commons DbUtils
>          Issue Type: New Feature
>    Affects Versions: 1.6
>            Reporter: Simone Tripodi
>            Assignee: Simone Tripodi
>             Fix For: 1.6
>
>         Attachments: DBUTILS-97.patch
>
>
> According to the DRY principle (Don't Repeat Yourself), repeating {{resultSet}} variable inside the {{ResultSetHandler#handle(ResultSet)}} over and over for each iteration can get a little tedious.
> It would be helpful adding a support class, named {{AbstractResultSetHandler}}, which implicitly gives users access to {{ResultSet}}'s methods. _For example_, we could extend {{AbstractResultSetHandler}} and rewrite the mapping below:
> {code}
> new ResultSetHandler<Collection<Map<String, Object>>> {
>     @Override
>     public Collection<Map<String, Object>> handle(ResultSet rs) throws SQLException {
>         Collection<Map<String, Object>> result = new LinkedList<Map<String, Object>>();
>         while (rs.next()) {
>             Map<String, Object> current = new HashMap<String, Object>();
>             for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++) {
>                 current.put(rs.getMetaData().getColumnName(i), rs.getObject(i));
>             }
>             result.add(current);
>         }
>         return result;
>     }
> }
> {code}
> as:
> {code}
> new AbstractResultSetHandler<Collection<Map<String, Object>>> {
>     @Override
>     protected Collection<Map<String, Object>> handle() throws SQLException {
>         Collection<Map<String, Object>> result = new LinkedList<Map<String, Object>>();
>         while (next()) {
>             Map<String, Object> current = new HashMap<String, Object>();
>             for (int i = 1; i <= getMetaData().getColumnCount(); i++) {
>                 current.put(getMetaData().getColumnName(i), getObject(i));
>             }
>             result.add(current);
>         }
>         return result;
>     }
> }
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       
Reply | Threaded
Open this post in threaded view
|

[jira] [Updated] (DBUTILS-97) Add an AbstractResultSetHandler implementation in order to reduce redundant 'resultSet' variable invocation

ASF GitHub Bot (Jira)
In reply to this post by ASF GitHub Bot (Jira)

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

Simone Tripodi updated DBUTILS-97:
----------------------------------

    Attachment: DBUTILS-97.patch

Attached the patch wich contains proposed class to be added.

If no objections, I'll check it in.

TIA!
               

> Add an AbstractResultSetHandler implementation in order to reduce redundant 'resultSet' variable invocation
> -----------------------------------------------------------------------------------------------------------
>
>                 Key: DBUTILS-97
>                 URL: https://issues.apache.org/jira/browse/DBUTILS-97
>             Project: Commons DbUtils
>          Issue Type: New Feature
>    Affects Versions: 1.6
>            Reporter: Simone Tripodi
>            Assignee: Simone Tripodi
>             Fix For: 1.6
>
>         Attachments: DBUTILS-97.patch
>
>
> According to the DRY principle (Don't Repeat Yourself), repeating {{resultSet}} variable inside the {{ResultSetHandler#handle(ResultSet)}} over and over for each iteration can get a little tedious.
> It would be helpful adding a support class, named {{AbstractResultSetHandler}}, which implicitly gives users access to {{ResultSet}}'s methods. _For example_, we could extend {{AbstractResultSetHandler}} and rewrite the mapping below:
> {code}
> new ResultSetHandler<Collection<Map<String, Object>>> {
>     @Override
>     public Collection<Map<String, Object>> handle(ResultSet rs) throws SQLException {
>         Collection<Map<String, Object>> result = new LinkedList<Map<String, Object>>();
>         while (rs.next()) {
>             Map<String, Object> current = new HashMap<String, Object>();
>             for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++) {
>                 current.put(rs.getMetaData().getColumnName(i), rs.getObject(i));
>             }
>             result.add(current);
>         }
>         return result;
>     }
> }
> {code}
> as:
> {code}
> new AbstractResultSetHandler<Collection<Map<String, Object>>> {
>     @Override
>     protected Collection<Map<String, Object>> handle() throws SQLException {
>         Collection<Map<String, Object>> result = new LinkedList<Map<String, Object>>();
>         while (next()) {
>             Map<String, Object> current = new HashMap<String, Object>();
>             for (int i = 1; i <= getMetaData().getColumnCount(); i++) {
>                 current.put(getMetaData().getColumnName(i), getObject(i));
>             }
>             result.add(current);
>         }
>         return result;
>     }
> }
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       
Reply | Threaded
Open this post in threaded view
|

[jira] [Commented] (DBUTILS-97) Add an AbstractResultSetHandler implementation in order to reduce redundant 'resultSet' variable invocation

ASF GitHub Bot (Jira)
In reply to this post by ASF GitHub Bot (Jira)

    [ https://issues.apache.org/jira/browse/DBUTILS-97?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13429334#comment-13429334 ]

William R. Speirs commented on DBUTILS-97:
------------------------------------------

I'm not sure if we want to set rs to null in the finally. Wouldn't this be more of a use-once object? Couldn't there be threading issues if the same instance of AbstractResultSetHandler were used more than once with different result sets? (I'm not sure how that would happen, but...)
               

> Add an AbstractResultSetHandler implementation in order to reduce redundant 'resultSet' variable invocation
> -----------------------------------------------------------------------------------------------------------
>
>                 Key: DBUTILS-97
>                 URL: https://issues.apache.org/jira/browse/DBUTILS-97
>             Project: Commons DbUtils
>          Issue Type: New Feature
>    Affects Versions: 1.6
>            Reporter: Simone Tripodi
>            Assignee: Simone Tripodi
>             Fix For: 1.6
>
>         Attachments: DBUTILS-97.patch
>
>
> According to the DRY principle (Don't Repeat Yourself), repeating {{resultSet}} variable inside the {{ResultSetHandler#handle(ResultSet)}} over and over for each iteration can get a little tedious.
> It would be helpful adding a support class, named {{AbstractResultSetHandler}}, which implicitly gives users access to {{ResultSet}}'s methods. _For example_, we could extend {{AbstractResultSetHandler}} and rewrite the mapping below:
> {code}
> new ResultSetHandler<Collection<Map<String, Object>>> {
>     @Override
>     public Collection<Map<String, Object>> handle(ResultSet rs) throws SQLException {
>         Collection<Map<String, Object>> result = new LinkedList<Map<String, Object>>();
>         while (rs.next()) {
>             Map<String, Object> current = new HashMap<String, Object>();
>             for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++) {
>                 current.put(rs.getMetaData().getColumnName(i), rs.getObject(i));
>             }
>             result.add(current);
>         }
>         return result;
>     }
> }
> {code}
> as:
> {code}
> new AbstractResultSetHandler<Collection<Map<String, Object>>> {
>     @Override
>     protected Collection<Map<String, Object>> handle() throws SQLException {
>         Collection<Map<String, Object>> result = new LinkedList<Map<String, Object>>();
>         while (next()) {
>             Map<String, Object> current = new HashMap<String, Object>();
>             for (int i = 1; i <= getMetaData().getColumnCount(); i++) {
>                 current.put(getMetaData().getColumnName(i), getObject(i));
>             }
>             result.add(current);
>         }
>         return result;
>     }
> }
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       
Reply | Threaded
Open this post in threaded view
|

[jira] [Commented] (DBUTILS-97) Add an AbstractResultSetHandler implementation in order to reduce redundant 'resultSet' variable invocation

ASF GitHub Bot (Jira)
In reply to this post by ASF GitHub Bot (Jira)

    [ https://issues.apache.org/jira/browse/DBUTILS-97?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13429390#comment-13429390 ]

Simone Tripodi commented on DBUTILS-97:
---------------------------------------

Yes the {{AbstractResultSetHandler}} is not thread-safety - and if the same instance would be used more than once at the same time, it would throw an {{IllegalStateException}}

The {{rs}} is set to null at the end of the method invocation to make the handler instance available to other call.

Just for the record: the pattern takes inspiration from the Google Guice Module (and related Abstract implementation).
               

> Add an AbstractResultSetHandler implementation in order to reduce redundant 'resultSet' variable invocation
> -----------------------------------------------------------------------------------------------------------
>
>                 Key: DBUTILS-97
>                 URL: https://issues.apache.org/jira/browse/DBUTILS-97
>             Project: Commons DbUtils
>          Issue Type: New Feature
>    Affects Versions: 1.6
>            Reporter: Simone Tripodi
>            Assignee: Simone Tripodi
>             Fix For: 1.6
>
>         Attachments: DBUTILS-97.patch
>
>
> According to the DRY principle (Don't Repeat Yourself), repeating {{resultSet}} variable inside the {{ResultSetHandler#handle(ResultSet)}} over and over for each iteration can get a little tedious.
> It would be helpful adding a support class, named {{AbstractResultSetHandler}}, which implicitly gives users access to {{ResultSet}}'s methods. _For example_, we could extend {{AbstractResultSetHandler}} and rewrite the mapping below:
> {code}
> new ResultSetHandler<Collection<Map<String, Object>>> {
>     @Override
>     public Collection<Map<String, Object>> handle(ResultSet rs) throws SQLException {
>         Collection<Map<String, Object>> result = new LinkedList<Map<String, Object>>();
>         while (rs.next()) {
>             Map<String, Object> current = new HashMap<String, Object>();
>             for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++) {
>                 current.put(rs.getMetaData().getColumnName(i), rs.getObject(i));
>             }
>             result.add(current);
>         }
>         return result;
>     }
> }
> {code}
> as:
> {code}
> new AbstractResultSetHandler<Collection<Map<String, Object>>> {
>     @Override
>     protected Collection<Map<String, Object>> handle() throws SQLException {
>         Collection<Map<String, Object>> result = new LinkedList<Map<String, Object>>();
>         while (next()) {
>             Map<String, Object> current = new HashMap<String, Object>();
>             for (int i = 1; i <= getMetaData().getColumnCount(); i++) {
>                 current.put(getMetaData().getColumnName(i), getObject(i));
>             }
>             result.add(current);
>         }
>         return result;
>     }
> }
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       
Reply | Threaded
Open this post in threaded view
|

[jira] [Commented] (DBUTILS-97) Add an AbstractResultSetHandler implementation in order to reduce redundant 'resultSet' variable invocation

ASF GitHub Bot (Jira)
In reply to this post by ASF GitHub Bot (Jira)

    [ https://issues.apache.org/jira/browse/DBUTILS-97?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13460370#comment-13460370 ]

Simone Tripodi commented on DBUTILS-97:
---------------------------------------

Any other though, Bill? If you don't have objections, I'll check it in!

TIA!
               

> Add an AbstractResultSetHandler implementation in order to reduce redundant 'resultSet' variable invocation
> -----------------------------------------------------------------------------------------------------------
>
>                 Key: DBUTILS-97
>                 URL: https://issues.apache.org/jira/browse/DBUTILS-97
>             Project: Commons DbUtils
>          Issue Type: New Feature
>    Affects Versions: 1.6
>            Reporter: Simone Tripodi
>            Assignee: Simone Tripodi
>             Fix For: 1.6
>
>         Attachments: DBUTILS-97.patch
>
>
> According to the DRY principle (Don't Repeat Yourself), repeating {{resultSet}} variable inside the {{ResultSetHandler#handle(ResultSet)}} over and over for each iteration can get a little tedious.
> It would be helpful adding a support class, named {{AbstractResultSetHandler}}, which implicitly gives users access to {{ResultSet}}'s methods. _For example_, we could extend {{AbstractResultSetHandler}} and rewrite the mapping below:
> {code}
> new ResultSetHandler<Collection<Map<String, Object>>> {
>     @Override
>     public Collection<Map<String, Object>> handle(ResultSet rs) throws SQLException {
>         Collection<Map<String, Object>> result = new LinkedList<Map<String, Object>>();
>         while (rs.next()) {
>             Map<String, Object> current = new HashMap<String, Object>();
>             for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++) {
>                 current.put(rs.getMetaData().getColumnName(i), rs.getObject(i));
>             }
>             result.add(current);
>         }
>         return result;
>     }
> }
> {code}
> as:
> {code}
> new AbstractResultSetHandler<Collection<Map<String, Object>>> {
>     @Override
>     protected Collection<Map<String, Object>> handle() throws SQLException {
>         Collection<Map<String, Object>> result = new LinkedList<Map<String, Object>>();
>         while (next()) {
>             Map<String, Object> current = new HashMap<String, Object>();
>             for (int i = 1; i <= getMetaData().getColumnCount(); i++) {
>                 current.put(getMetaData().getColumnName(i), getObject(i));
>             }
>             result.add(current);
>         }
>         return result;
>     }
> }
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
Reply | Threaded
Open this post in threaded view
|

[jira] [Commented] (DBUTILS-97) Add an AbstractResultSetHandler implementation in order to reduce redundant 'resultSet' variable invocation

ASF GitHub Bot (Jira)
In reply to this post by ASF GitHub Bot (Jira)

    [ https://issues.apache.org/jira/browse/DBUTILS-97?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13460395#comment-13460395 ]

William R. Speirs commented on DBUTILS-97:
------------------------------------------

Sounds good, go for it! Thanks...
               

> Add an AbstractResultSetHandler implementation in order to reduce redundant 'resultSet' variable invocation
> -----------------------------------------------------------------------------------------------------------
>
>                 Key: DBUTILS-97
>                 URL: https://issues.apache.org/jira/browse/DBUTILS-97
>             Project: Commons DbUtils
>          Issue Type: New Feature
>    Affects Versions: 1.6
>            Reporter: Simone Tripodi
>            Assignee: Simone Tripodi
>             Fix For: 1.6
>
>         Attachments: DBUTILS-97.patch
>
>
> According to the DRY principle (Don't Repeat Yourself), repeating {{resultSet}} variable inside the {{ResultSetHandler#handle(ResultSet)}} over and over for each iteration can get a little tedious.
> It would be helpful adding a support class, named {{AbstractResultSetHandler}}, which implicitly gives users access to {{ResultSet}}'s methods. _For example_, we could extend {{AbstractResultSetHandler}} and rewrite the mapping below:
> {code}
> new ResultSetHandler<Collection<Map<String, Object>>> {
>     @Override
>     public Collection<Map<String, Object>> handle(ResultSet rs) throws SQLException {
>         Collection<Map<String, Object>> result = new LinkedList<Map<String, Object>>();
>         while (rs.next()) {
>             Map<String, Object> current = new HashMap<String, Object>();
>             for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++) {
>                 current.put(rs.getMetaData().getColumnName(i), rs.getObject(i));
>             }
>             result.add(current);
>         }
>         return result;
>     }
> }
> {code}
> as:
> {code}
> new AbstractResultSetHandler<Collection<Map<String, Object>>> {
>     @Override
>     protected Collection<Map<String, Object>> handle() throws SQLException {
>         Collection<Map<String, Object>> result = new LinkedList<Map<String, Object>>();
>         while (next()) {
>             Map<String, Object> current = new HashMap<String, Object>();
>             for (int i = 1; i <= getMetaData().getColumnCount(); i++) {
>                 current.put(getMetaData().getColumnName(i), getObject(i));
>             }
>             result.add(current);
>         }
>         return result;
>     }
> }
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
Reply | Threaded
Open this post in threaded view
|

[jira] [Updated] (DBUTILS-97) Add an Abstract ResultSetHandler implementation in order to reduce redundant 'resultSet' variable invocation

ASF GitHub Bot (Jira)
In reply to this post by ASF GitHub Bot (Jira)

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

Simone Tripodi updated DBUTILS-97:
----------------------------------

    Summary: Add an Abstract ResultSetHandler implementation in order to reduce redundant 'resultSet' variable invocation  (was: Add an AbstractResultSetHandler implementation in order to reduce redundant 'resultSet' variable invocation)
   

> Add an Abstract ResultSetHandler implementation in order to reduce redundant 'resultSet' variable invocation
> ------------------------------------------------------------------------------------------------------------
>
>                 Key: DBUTILS-97
>                 URL: https://issues.apache.org/jira/browse/DBUTILS-97
>             Project: Commons DbUtils
>          Issue Type: New Feature
>    Affects Versions: 1.6
>            Reporter: Simone Tripodi
>            Assignee: Simone Tripodi
>             Fix For: 1.6
>
>         Attachments: DBUTILS-97.patch
>
>
> According to the DRY principle (Don't Repeat Yourself), repeating {{resultSet}} variable inside the {{ResultSetHandler#handle(ResultSet)}} over and over for each iteration can get a little tedious.
> It would be helpful adding a support class, named {{AbstractResultSetHandler}}, which implicitly gives users access to {{ResultSet}}'s methods. _For example_, we could extend {{AbstractResultSetHandler}} and rewrite the mapping below:
> {code}
> new ResultSetHandler<Collection<Map<String, Object>>> {
>     @Override
>     public Collection<Map<String, Object>> handle(ResultSet rs) throws SQLException {
>         Collection<Map<String, Object>> result = new LinkedList<Map<String, Object>>();
>         while (rs.next()) {
>             Map<String, Object> current = new HashMap<String, Object>();
>             for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++) {
>                 current.put(rs.getMetaData().getColumnName(i), rs.getObject(i));
>             }
>             result.add(current);
>         }
>         return result;
>     }
> }
> {code}
> as:
> {code}
> new AbstractResultSetHandler<Collection<Map<String, Object>>> {
>     @Override
>     protected Collection<Map<String, Object>> handle() throws SQLException {
>         Collection<Map<String, Object>> result = new LinkedList<Map<String, Object>>();
>         while (next()) {
>             Map<String, Object> current = new HashMap<String, Object>();
>             for (int i = 1; i <= getMetaData().getColumnCount(); i++) {
>                 current.put(getMetaData().getColumnName(i), getObject(i));
>             }
>             result.add(current);
>         }
>         return result;
>     }
> }
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
Reply | Threaded
Open this post in threaded view
|

[jira] [Resolved] (DBUTILS-97) Add an Abstract ResultSetHandler implementation in order to reduce redundant 'resultSet' variable invocation

ASF GitHub Bot (Jira)
In reply to this post by ASF GitHub Bot (Jira)

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

Simone Tripodi resolved DBUTILS-97.
-----------------------------------

    Resolution: Fixed

Thanks a lot for your feedback Bill, I just checked in a modified version of the patch (a little more of Javadoc, I preferred prefixing {{Base}} rather than {{Abstract}} the abstract class)

You can see the changes by reviewing [r1388495|http://svn.apache.org/viewvc?rev=1388495&view=rev]

Best,
-Simo
               

> Add an Abstract ResultSetHandler implementation in order to reduce redundant 'resultSet' variable invocation
> ------------------------------------------------------------------------------------------------------------
>
>                 Key: DBUTILS-97
>                 URL: https://issues.apache.org/jira/browse/DBUTILS-97
>             Project: Commons DbUtils
>          Issue Type: New Feature
>    Affects Versions: 1.6
>            Reporter: Simone Tripodi
>            Assignee: Simone Tripodi
>             Fix For: 1.6
>
>         Attachments: DBUTILS-97.patch
>
>
> According to the DRY principle (Don't Repeat Yourself), repeating {{resultSet}} variable inside the {{ResultSetHandler#handle(ResultSet)}} over and over for each iteration can get a little tedious.
> It would be helpful adding a support class, named {{AbstractResultSetHandler}}, which implicitly gives users access to {{ResultSet}}'s methods. _For example_, we could extend {{AbstractResultSetHandler}} and rewrite the mapping below:
> {code}
> new ResultSetHandler<Collection<Map<String, Object>>> {
>     @Override
>     public Collection<Map<String, Object>> handle(ResultSet rs) throws SQLException {
>         Collection<Map<String, Object>> result = new LinkedList<Map<String, Object>>();
>         while (rs.next()) {
>             Map<String, Object> current = new HashMap<String, Object>();
>             for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++) {
>                 current.put(rs.getMetaData().getColumnName(i), rs.getObject(i));
>             }
>             result.add(current);
>         }
>         return result;
>     }
> }
> {code}
> as:
> {code}
> new AbstractResultSetHandler<Collection<Map<String, Object>>> {
>     @Override
>     protected Collection<Map<String, Object>> handle() throws SQLException {
>         Collection<Map<String, Object>> result = new LinkedList<Map<String, Object>>();
>         while (next()) {
>             Map<String, Object> current = new HashMap<String, Object>();
>             for (int i = 1; i <= getMetaData().getColumnCount(); i++) {
>                 current.put(getMetaData().getColumnName(i), getObject(i));
>             }
>             result.add(current);
>         }
>         return result;
>     }
> }
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira