You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by thiamteck <th...@gmail.com> on 2007/12/26 05:10:16 UTC

spliting iBatis query result

hi,

I am experiment with Camel before use it in production. I start with iBatis
component. I try to query record from a table via iBatis and then route it
to another table via iBatis.

from("ibatis://test.getMsg").to("ibatis://test.insertMsg");

The problem i face is, "test.getMsg" return an ArrayList of the result
object, while "test.insertMsg" expecting a individual object instead of
ArrayList.

Is there any way to split the ArrayList into multiple objects in the list so
that the insert statement can work?

Thank you.

Truly,
Thiam Teck


-- 
View this message in context: http://www.nabble.com/spliting-iBatis-query-result-tp14499404s22882p14499404.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: spliting iBatis query result

Posted by James Strachan <ja...@gmail.com>.
On 27/12/2007, Roman Kalukiewicz <ro...@gmail.com> wrote:
> 2007/12/26, thiamteck <th...@gmail.com>:
> >
> > hi,
> >
> > I am experiment with Camel before use it in production. I start with iBatis
> > component. I try to query record from a table via iBatis and then route it
> > to another table via iBatis.
> >
> > from("ibatis://test.getMsg").to("ibatis://test.insertMsg");
> >
> > The problem i face is, "test.getMsg" return an ArrayList of the result
> > object, while "test.insertMsg" expecting a individual object instead of
> > ArrayList.
> >
> > Is there any way to split the ArrayList into multiple objects in the list so
> > that the insert statement can work?
>
> Maybe you should simply use splitter? As the message body is already
> an array it should be enough to do it this way:
>
> from("ibatis://test.getMsg").splitter(body()).to("ibatis://test.insertMsg");

Good idea!

I kinda figured that the iBatis should try to do the right thing by
default if it can. So I've applied a trivial patch to the iBatis
component (IBatisProducer to be precise) to automatically deal with
Collections or arrays of objects when evaluating insert/update
operations so that it does the right thing by default. Here's the
JIRA...
https://issues.apache.org/activemq/browse/CAMEL-282

-- 
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://open.iona.com

Re: spliting iBatis query result

Posted by Roman Kalukiewicz <ro...@gmail.com>.
2007/12/26, thiamteck <th...@gmail.com>:
>
> hi,
>
> I am experiment with Camel before use it in production. I start with iBatis
> component. I try to query record from a table via iBatis and then route it
> to another table via iBatis.
>
> from("ibatis://test.getMsg").to("ibatis://test.insertMsg");
>
> The problem i face is, "test.getMsg" return an ArrayList of the result
> object, while "test.insertMsg" expecting a individual object instead of
> ArrayList.
>
> Is there any way to split the ArrayList into multiple objects in the list so
> that the insert statement can work?

Maybe you should simply use splitter? As the message body is already
an array it should be enough to do it this way:

from("ibatis://test.getMsg").splitter(body()).to("ibatis://test.insertMsg");

Roman