ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Clinton Begin <clinton.be...@gmail.com>
Subject Re: Returning Three ArrayLists
Date Thu, 20 Aug 2009 12:44:30 GMT
It's against the design of SQL and JDBC, but not iBATIS.... :-)

Just write a custom RowHandler (or ResultHandler in iBATIS 3).

I'll use pseudocode since I don't know which version you're using....

//assume you just map the results to a HashMap originally

List list1;
List list2;
List list3;
handleResult(Object result) {
  Map map = (Map) result;
  list1.add(map.get("Number1");
  list2.add(map.get("Number2");
  list3.add(map.get("Number3");
}

Clinton

On Thu, Aug 20, 2009 at 1:51 AM, Richard Bibb <richard.bibb@aimhedge.com>wrote:

>
> I think I'm probably trying to use iBatis in a way that goes against it's
> design, but for what I need to do it's correct.
>
> If I have a query like:
>
> select Number1, Number2, Number3
> from SOME_TABLE
> where COL_DATE > EARLY_TIME
> and COLD_DATE < LATER_TIME
>
> Assume that the query returns many rows,
>
> I would like to be able to return this data as three ArrayList<Double>. I
> know I can return one ArrayList<SomeClass> where SomeClass contains three
> numbers but that just adds a second layer of processing that I don't want
> to
> do. I also know I could do three separate queries but as some of the
> numbers
> may not have entries on some days it would again add a layer of processing
> to add null data back into the ArrayLists returned
>
> I tried doing a result map containing three collections but the data
> returned was wrong (all of the collections seemed to get populated with
> data
> from the first row).
> --
> View this message in context:
> http://www.nabble.com/Returning-Three-ArrayLists-tp25057560p25057560.html
> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
> For additional commands, e-mail: user-java-help@ibatis.apache.org
>
>

Mime
View raw message