camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: Update database using Java DSL JPA
Date Mon, 04 Mar 2013 15:44:37 GMT
On Mon, Mar 4, 2013 at 4:31 PM, golivamsi84 <golivamsi84@gmail.com> wrote:
> Hello,
>
> I am pretty new in using camel and we are just trying to incorporate it in
> our architecture, so everyone here is pretty new to Camel. So please forgive
> me if this so basic question.
>

Welcome to the community.


> Question:
> I am trying to access and update oracle database using JPA Hibernate. So I
> created my route for now which reads data from the database, I believe it
> just runs a select query and I can see the results.
>
> from("oracleJpa://com.nationwide.financialresponsibility.model.Driver?consumeDelete=false&maximumResults=3&consumer.delay=5000")
>                 .to("stream:out");
>
> So can someone help me how I can update records in the database.Please
> explain me in detail if you can so that I can understand the flow. We are
> struggling on this one for a while now.
>

It depends what you want to update.

The JPA component in the <from> is designed to be a data transfer with
a table having the data.
So the idea is that Camel polls the table for new row(s). And after
they have been processed.
The row(s) can either be DELETED or UPDATED. And for updated you would
for example need
to set some column as a "flag" to indicate they have been processed.
So on the next poll these row(s)
is not picked up again.

There is a @Consumed  annotation you should add to a method on your
Entity bean. Then Camel calls that to update the entity. Then you can
use java code to set the "flag".

There is a little example from unti test here
https://svn.apache.org/repos/asf/camel/trunk/components/camel-jpa/src/test/java/org/apache/camel/examples/MultiSteps.java

> thanks
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Update-database-using-Java-DSL-JPA-tp5728463.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cibsen@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Mime
View raw message