camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Wilson MacGyver <wmacgy...@gmail.com>
Subject using JPA to update database
Date Tue, 02 Jun 2015 05:17:45 GMT
Hi,

here is what I'm trying to do, but I'm not sure if I'm on the right track
or not.

I have a inbound file that I want to process, and use it to either create or
update existing rows in a table. I know I can do this using camel-jdbc, but
I wanted to see if it can be done with jpa

I know to use jpa with namedparameters I have to use it as a consumer.

and I need to use jpa mid-route as a consumer, and namedparamters can only
be
set using registry.

so I was thinking of flow like this

from("direct:fileprocess")
  .//bindy to process file
  .process(new SetQueryIdProcessor) // to find the id in the current line
of the file, and set it in registry
  .pollEnrich("jpa:" + Entity.class.getName() +
"?consumeDelete=false&consumer.namedQuery=findById&
   consumer.parameters=#params")  // to see if the record already exist

and then based on that, either update existing record, or create new one.
Am I on the right track? Is this doable
or is camel-jdbc the only way?

Thanks




-- 
Omnem crede diem tibi diluxisse supremum.

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message