Issue Details (XML | Word | Printable)

Key: DBUTILS-47
Type: New Feature New Feature
Status: Closed Closed
Resolution: Won't Fix
Priority: Minor Minor
Assignee: Unassigned
Reporter: Olivier Grégoire
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Commons DbUtils

Add a StatementFiller to be able to provide a Bean for updates, instead of bean values.

Created: 01/Dec/08 09:40 PM   Updated: 07/Mar/09 06:04 AM
Return to search
Component/s: None
Affects Version/s: 1.1
Fix Version/s: None

Time Tracking:
Not Specified

Issue Links:
Duplicate
 

Resolution Date: 26/Feb/09 03:22 AM


 Description  « Hide
When using the QueryRunner, in conjunction with the ResultSetHandler interface, we got awesome results. Everything seems to be easier... except when it comes to update an object to the database.

To solve this, what I request is adding a new interface that allows to easily fill a statement with a bean, instead of a list of values (Object).

The interface should be something like this:

public interface StatementFiller {
public void fillStatement (Statement stmt, Object bean) throws SQLException;
}

and can be called in an update() like this:

public int update(Connection connection, String sql, StatementFiller filler, Object bean)
throws SQLException {
PreparedStatement statement = null;
try { statement = this.prepareStatement(connection, sql); filler.fillStatement(statement, bean); return statement.executeUpdate(); } catch (SQLException e) { throw this.nestException(e, sql, bean); } finally { close(statement); }
}

What is clearly the advantage of this? Simply that we can use only one QueryRunner and any amount of statement fillers, just like there exist a lot of ResultSetHandler. There is no more need to override the QueryRunner's statementFiller.

To keep backward compatibility, QueryRunner may implement that interface and be provided as the default Filler, so the current behavior is not lost.

(Sorry for not showing the actual sources of DButils: I don't have them right here, I used my tweaked version instead).



 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Dan Fabulich added a comment - 05/Feb/09 04:15 PM
This is the same issue as DBUTILS-29, though I like the idea of a StatementFiller interface.

Henri Yandell added a comment - 26/Feb/09 03:22 AM
DBUTILS-29 has been applied and this is viewed as duplicated functionality.

Dan Fabulich added a comment - 07/Mar/09 06:04 AM
Removing "Fix Version: 1.2" since dupes/invalid/wontfix bugs clutter the release notes.