On Sat, May 28, 2011 at 10:19 PM, sumatheja <[email protected]> wrote:
> Hi All,
>         I have a requirement to read from csv and populate a table in
> database. Currently i'm able to read from the csv using camelbindy
>
>                                 from("file:src/data?noop=true&delay=10000")
>                                        .unmarshal().bindy(BindyType.Csv, 
> "camelinaction")
>
> I have all the correct setting for the db and the right entity
> bean(PurchaseOrder)
>
> Can you tell me how to redirect the output from the above endpoint to JPA
> component...... When i just tried adding
>
>
> .to("jpa:camelinaction.PurchaseOrder")
>
> Its giving type mismatch error as the bindy is returning list and jpa
> component is awaiting a bean.
>
> Any help will be appreciated...
>

Camel is based on the EIPs listed here
http://camel.apache.org/eip

So what you need to do is to use the splitter EIP to go from the List
-> process each element in the list.
http://camel.apache.org/splitter

from("file:src/data?noop=true&delay=10000")
    .unmarshal().bindy(BindyType.Csv, "camelinaction")
    .split(body())
          .to("jpa:camelinaction.PurchaseOrder");

Something like above, where we use the split and tell Camel to split
the message body. (It knows how to iterate the list from the body)


> thanks in advance
>
> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/CSV-to-database-tp4435750p4435750.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: [email protected]
Web: http://fusesource.com
CamelOne 2011: http://fusesource.com/camelone2011/
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Reply via email to