[ 
http://issues.apache.org/jira/browse/IBATIS-226?page=comments#action_12359001 ] 

Paul Benedict commented on IBATIS-226:
--------------------------------------

I haved talked with Larry privately about these ideas and now I am taking them 
public for review.

I think we can provide callback hooks into iBATIS at the DAO level. So we would 
have new overloaded methods like:
queryForList(name, params, callback);

Where callback can implement one to many interfaces:

public interface ResultSetHandler {
  public Object handle(ResultSet);
}

public interface StatementHandler {
  public boolean preProcess(StatementContext cxt);
  public boolean postProcess(StatementContext cxt);
}

I have broken up these 3 methods into 2 interfaces so iBATIS doesn't have to 
perform callbacks on operations that are not requested by the developer. iBATIS 
will inspect the callback interfaces to see what is supported and invoke them 
if they are present.

The ResultSetHandler (could be from the DbUtils package) allows programatic 
access to build the returning object. Useful for advanced situations (and can 
be used to override any resultMap present). 

The StatementHandler I propose takes usage of the commons-chain package. This 
will allow people to build processing chains before and after the statement 
executes. Why chain? If you give people the option to do processing, eventually 
someone will build a chain so we might as well support it out-of-the-box and 
tout our features. :-) Also the StatementContext object would contain metadata 
about the current statement invocation and expose objects such as the 
MappedStatement, parameters passed in, even the built SQL. Some of these 
properties will be read-write so that people can modify the generated SQL 
before it gets executed. Larry suggested this would be a good way to use iBATIS 
to generate dynamic HQL and then turn it into SQL.

OK. Let's hear it!

> Support Commons DBUtils ResultSetHandler
> ----------------------------------------
>
>          Key: IBATIS-226
>          URL: http://issues.apache.org/jira/browse/IBATIS-226
>      Project: iBatis for Java
>         Type: New Feature
>   Components: SQL Maps
>     Reporter: Paul Benedict

>
> Sometimes I need total control over the caching mechanism for very critical 
> systems. I need to also guarantee object identity and I can only do this when 
> handling the result set myself. I propose adding an attribute to the 
> <statement> tag (and also <select>, <insert>, <update>) that will specify a 
> subclass of ResultSetHandler so that I may write custom code and decode the 
> ResultSet myself. The ResultSetHandler class is part of the Jakarta Commons 
> DBUtils package. It is extremely useful!
> <select id="findMyObject" resultSetHandler="com.company.MyResultSetHandler">
> To prevent excess object creation, IBATIS must reuse the same instance it 
> creates. 

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira

Reply via email to