You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Tegan Clark <te...@yahoo.com> on 2007/01/04 17:20:57 UTC

Getting straight at the ResultSet

Hi group;
   
  I was wondering if there is any way to receive the ResultSet back straight from iBATIS, i.e. allow iBATIS to do the mapping on the way in, but let me manipulate the ResultSet directly on the way out.
   
  I have a framework that uses iBATIS to product "no-code" reports (just the xml).  Some of those reports can stretch to 100,000's or records though so are better suited to an iterator approach and non-reflective mapping.
   
  If it can't be done, is this something iBATIS would be interested in having contributed?
   
  All help greatly appreciated.  Thanks.
   
  Tegan

 __________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

RE: Getting straight at the ResultSet

Posted by Damien McCarthy <da...@propylon.com>.
Hi Tegan,

 

I'm not sure which overhead you are trying to avoid..

 

If you want to avoid loading 100,000 objects into memory at the same time,
then the RowHandler will do this for you. The row handler will walk along
the resultSet and for each row call handleRow. So you would expect this
method to be called 100,000 times. For example inside this method you could
put code to append some of the objects properties to a file. This gives you
the iterative approach you mentioned in your first mail.

 

If you want to avoid mapping the 100,000 rows to objects at any time then
why are you using ibatis at all?  Just use a direct JDBC connection.

 

Damien

 

From: Tegan Clark [mailto:tegan.clark@yahoo.com] 
Sent: 04 January 2007 20:02
To: user-java@ibatis.apache.org
Subject: RE: Getting straight at the ResultSet

 

Damien/Larry,

 

Thanks for the reply.  I've looked at RowHandler, and unless I'm missing
something iBATIS is still controlling the iteration and passing me a Map of
the underlying data, i.e. iBATIS first incures the overhead of adapting the
ResultSet to the Map, and then I must implement some sought of buffer to
hold the returned results (unless I implement some sought of callback out of
my DAL).

 

Do my assumptions above sound correct?

 

There's no way to map the ResultSet straight back? i.e:

 

   ResultSet res = (ResultSet ) sqlClient.queryForObject();

 

Thanks again.

 

Tegan

 


Damien McCarthy <da...@propylon.com> wrote:

 

I have a framework that uses iBATIS to product "no-code" reports (just the
xml).  Some of those reports can stretch to 100,000's or records though so
are better suited to an iterator approach and non-reflective mapping.

 

If it can't be done, is this something iBATIS would be interested in having
contributed?

 

All help greatly appreciated.  Thanks.

 

Tegan

 __________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

 

 __________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


RE: Getting straight at the ResultSet

Posted by Abdullah Kauchali <ab...@isanusi.com>.
Hi Tegan,

 

I once made a feature request for something like this:

 

http://issues.apache.org/jira/browse/IBATIS-206

 

It didn’t receive any serious consideration though, perhaps more on grounds
of ideology than of practicality.

 

The basis of my request was that if we have the RowHandler facility, why
don’t we have disconnected ResultSets too?  Paradigmatically, they are the
same – except that iBatis’s RowHandler is a much abstracted high level
interface.  With disconnected ResultSets we can access meta-data objects too
(something we currently can’t do with iBatis).  I have since been working
with my own patched version of iBatis to support my requirements vis-à-vis
disconnected ResultSets.  No problems. 

 

If you are going to do something similar, just note that returning the
true-blue JDBC ResultSet (the non-serializable one) from iBatis should be
avoided because JDBC ResultSets are linked to implicit connection objects to
your database.  Even though you won’t be able to transfer your “connected”
JDBC Resultset across process boundaries, you still don’t want them to be
passed around in your DAL.  Rather work with disconnected versions of them.
(Also, SqlMapClient already abstracts the connection details for you nicely
and allows you to control transactions too.)  

 

So, what you may want to have a look at are *disconnected* Resultsets via
JDBC 3.0’s CachedRowSet interface (and all the other incarnations WebRowSet
etc).  This way you can bypass all the ResultSet-to-object mapping overhead
too – if you don’t need it. 

 

Hope that helps,

 

Kind regards,

 

Abdullah

 

 

 

  _____  

From: Tegan Clark [mailto:tegan.clark@yahoo.com] 
Sent: Thursday, January 04, 2007 10:02 PM
To: user-java@ibatis.apache.org
Subject: RE: Getting straight at the ResultSet

 

Damien/Larry,

 

Thanks for the reply.  I've looked at RowHandler, and unless I'm missing
something iBATIS is still controlling the iteration and passing me a Map of
the underlying data, i.e. iBATIS first incures the overhead of adapting the
ResultSet to the Map, and then I must implement some sought of buffer to
hold the returned results (unless I implement some sought of callback out of
my DAL).

 

Do my assumptions above sound correct?

 

There's no way to map the ResultSet straight back? i.e:

 

   ResultSet res = (ResultSet ) sqlClient.queryForObject();

 

Thanks again.

 

Tegan

 


Damien McCarthy <da...@propylon.com> wrote:

 

I have a framework that uses iBATIS to product "no-code" reports (just the
xml).  Some of those reports can stretch to 100,000's or records though so
are better suited to an iterator approach and non-reflective mapping.

 

If it can't be done, is this something iBATIS would be interested in having
contributed?

 

All help greatly appreciated.  Thanks.

 

Tegan

 __________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

 

 __________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


RE: Getting straight at the ResultSet

Posted by Tegan Clark <te...@yahoo.com>.
Damien/Larry,
   
  Thanks for the reply.  I've looked at RowHandler, and unless I'm missing something iBATIS is still controlling the iteration and passing me a Map of the underlying data, i.e. iBATIS first incures the overhead of adapting the ResultSet to the Map, and then I must implement some sought of buffer to hold the returned results (unless I implement some sought of callback out of my DAL).
   
  Do my assumptions above sound correct?
   
  There's no way to map the ResultSet straight back? i.e:
   
     ResultSet res = (ResultSet ) sqlClient.queryForObject();
   
  Thanks again.
   
  Tegan
   
  
Damien McCarthy <da...@propylon.com> wrote:
                Hi Tegan,
   
  I think the RowHandler interface will provide the functionality you need, this will allow you to iterate the objects. 
   
  Take a look in p61 of the developer handbook for a nice example 
   
  Damien.
   
  Ps. The Handbook is at : http://ibatis.apache.org/docs/java/pdf/iBATIS-SqlMaps-2_en.pdf
   
   
    From: Tegan Clark [mailto:tegan.clark@yahoo.com] 
Sent: 04 January 2007 16:21
To: user-java@ibatis.apache.org
Subject: Getting straight at the ResultSet

   
    Hi group;

     

    I was wondering if there is any way to receive the ResultSet back straight from iBATIS, i.e. allow iBATIS to do the mapping on the way in, but let me manipulate the ResultSet directly on the way out.

     

    I have a framework that uses iBATIS to product "no-code" reports (just the xml).  Some of those reports can stretch to 100,000's or records though so are better suited to an iterator approach and non-reflective mapping.

     

    If it can't be done, is this something iBATIS would be interested in having contributed?

     

    All help greatly appreciated.  Thanks.

     

    Tegan

   __________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 



 __________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

RE: Getting straight at the ResultSet

Posted by Damien McCarthy <da...@propylon.com>.
Hi Tegan,

 

I think the RowHandler interface will provide the functionality you need,
this will allow you to iterate the objects. 

 

Take a look in p61 of the developer handbook for a nice example 

 

Damien.

 

Ps. The Handbook is at :
http://ibatis.apache.org/docs/java/pdf/iBATIS-SqlMaps-2_en.pdf

 

 

From: Tegan Clark [mailto:tegan.clark@yahoo.com] 
Sent: 04 January 2007 16:21
To: user-java@ibatis.apache.org
Subject: Getting straight at the ResultSet

 

Hi group;

 

I was wondering if there is any way to receive the ResultSet back straight
from iBATIS, i.e. allow iBATIS to do the mapping on the way in, but let me
manipulate the ResultSet directly on the way out.

 

I have a framework that uses iBATIS to product "no-code" reports (just the
xml).  Some of those reports can stretch to 100,000's or records though so
are better suited to an iterator approach and non-reflective mapping.

 

If it can't be done, is this something iBATIS would be interested in having
contributed?

 

All help greatly appreciated.  Thanks.

 

Tegan

 __________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


Re: Getting straight at the ResultSet

Posted by Larry Meadors <lm...@apache.org>.
Have you tried using a row handler?

I have found them to be very efficient working with large datasets.

Larry

On 1/4/07, Tegan Clark <te...@yahoo.com> wrote:
> Hi group;
>
> I was wondering if there is any way to receive the ResultSet back straight
> from iBATIS, i.e. allow iBATIS to do the mapping on the way in, but let me
> manipulate the ResultSet directly on the way out.
>
> I have a framework that uses iBATIS to product "no-code" reports (just the
> xml).  Some of those reports can stretch to 100,000's or records though so
> are better suited to an iterator approach and non-reflective mapping.
>
> If it can't be done, is this something iBATIS would be interested in having
> contributed?
>
> All help greatly appreciated.  Thanks.
>
> Tegan
>
>  __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com