Details
-
New Feature
-
Status: Closed
-
Minor
-
Resolution: Won't Fix
-
1.1
-
None
-
None
Description
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
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).
Attachments
Issue Links
- duplicates
-
DBUTILS-29 [dbutils] Support bean property to SQL IN parameter mapping
- Closed