You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by imranrazakhan <im...@gmail.com> on 2014/03/01 08:29:19 UTC

JPAComponent starter example

Hi,

I am new to ApacheCamel and working on example which will select records
from table and display on console, following is what i tried

from("jpa:LoanRequest?consumeDelete=false;consumer.namedQuery=selectLoanRequests&persistenceUnit=LoanServicePU")
.to("stream:out");

but how i can get objects/rows list and display particular columns?

regards



--
View this message in context: http://camel.465427.n5.nabble.com/JPAComponent-starter-example-tp5748145.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: JPAComponent starter example

Posted by sekaijin <je...@sap.aphp.fr>.
you can read the christian blog at
http://www.liquid-reality.de/display/liquid/Karaf+Tutorials

Bye
A+JYT
PS: sorry for my approximative english



--
View this message in context: http://camel.465427.n5.nabble.com/JPAComponent-starter-example-tp5748145p5748154.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: JPAComponent starter example

Posted by imranrazakhan <im...@gmail.com>.
Hi,

Thanks for reply, i did this by creating processor

LoanRequest lr = exchange.getIn().getBody(LoanRequest.class);
System.out.println("After for loop");

How i could get multiple rows from db like

List<LoanRequest> requests  = exchange.getIn().getBody();

Regards






--
View this message in context: http://camel.465427.n5.nabble.com/JPAComponent-starter-example-tp5748145p5748153.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: JPAComponent starter example

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

The jpa consumer maps to java objects, eg you get each row as a
LoanRequest instance.

So if you want to show some particular information from this instance
in the stream, then you need to do a message transformation first
http://camel.apache.org/message-translator.html

You can use the simple language, velocity or other template languages etc.

from jpa
  transform simple("The ${body.foo} and ${body.bar} is cool stuff")
  to stream out

eg in the example above we transform the message with the simple
language and ${ } is dynamic tokens that is replaced with calling the
getFoo method on the body (= the loan request instance).
http://camel.apache.org/simple

In your use-case you would of course need to adjust this to what data
you have on the loan request instance.




On Sat, Mar 1, 2014 at 8:29 AM, imranrazakhan <im...@gmail.com> wrote:
> Hi,
>
> I am new to ApacheCamel and working on example which will select records
> from table and display on console, following is what i tried
>
> from("jpa:LoanRequest?consumeDelete=false;consumer.namedQuery=selectLoanRequests&persistenceUnit=LoanServicePU")
> .to("stream:out");
>
> but how i can get objects/rows list and display particular columns?
>
> regards
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/JPAComponent-starter-example-tp5748145.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
Make your Camel applications look hawt, try: http://hawt.io