MyBatis with resultType "ResultSet" or alternative result.

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

MyBatis with resultType "ResultSet" or alternative result.

Leszek Gawron
Hello, 
I have used MyBatis in one project with luck. What I like about it the most is the XML mapper files which allow me to build very large dynamic queries from chunks of sql code.

This is, there are times i would like only to use the sql statement preparation code of MyBatis and not actual mapping. For the performance reasons I would be perfectly happy if MyBatis handed me a ready to iterate ResultSet.
  - sometimes the ResultSet is way too big for putting results into list
  - sometimes mapping data to maps or pojos is simply a waste of memory and processing power.


Would that be possible? I tried digging into the source and failed. I wasn't able to isolate the classes that build and prepare the query from the logic that actually processes the results.

my regards
  Leszek Gawron

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply | Threaded
Open this post in threaded view
|

Re: MyBatis with resultType "ResultSet" or alternative result.

Ray Sprinkle
You should look at ResultHandler.

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.


Reply | Threaded
Open this post in threaded view
|

Re: MyBatis with resultType "ResultSet" or alternative result.

Leszek Gawron
The ResultHandler already performs the mapping. I would like to avoid that.

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.


Reply | Threaded
Open this post in threaded view
|

Re: MyBatis with resultType "ResultSet" or alternative result.

Guy Rouillier-2
On 3/22/2013 6:42 PM, Leszek Gawron wrote:
> The ResultHandler already performs the mapping. I would like to avoid that.
>
Which is why you were suggested to write your *own* ResultSetHandler.
You would replace the automatic mapping done by the default one.

--
Guy Rouillier

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.


Reply | Threaded
Open this post in threaded view
|

Re: MyBatis with resultType "ResultSet" or alternative result.

Ted Shaw
It seems you need implement the ResultSetHandler interface and hack sql mapping to support custom result set handler such as 

    <select id="getStreamResult" resultSetHander="mycustomHandler">
      select * from xx
    </select>

you can look at 
org.apache.ibatis.session.Configuration

  public ResultSetHandler newResultSetHandler(Executor executor, MappedStatement mappedStatement, RowBounds rowBounds, ParameterHandler parameterHandler,
      ResultHandler resultHandler, BoundSql boundSql) {
    ResultSetHandler resultSetHandler = mappedStatement.hasNestedResultMaps() ? new NestedResultSetHandler(executor, mappedStatement, parameterHandler, resultHandler, boundSql,
        rowBounds) : new FastResultSetHandler(executor, mappedStatement, parameterHandler, resultHandler, boundSql, rowBounds);
    resultSetHandler = (ResultSetHandler) interceptorChain.pluginAll(resultSetHandler);
    return resultSetHandler;
  }

and 
org.apache.ibatis.builder.xml.XMLMapperBuilder
 private ResultMapping buildResultMappingFromContext 

and don't' forget to update xml dtd definition.

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.