For anybody wants to try it before 2.19 release - it has been merged into
upstream.
https://github.com/apache/camel/blob/master/components/camel-jpa/src/main/docs/jpa-component.adoc
On 03/11/2017 08:59 AM, Tomohisa Igarashi wrote:
Hi,
As you can see the parameter name starts with 'consumer', it's a consumer
option. Right now JPA producer doesn't support named query yet. I'll work on
that enhancement soon.
https://issues.apache.org/jira/browse/CAMEL-10265
Thanks,
Tomo
On 03/11/2017 08:24 AM, urwithsumit wrote:
Hi,
I have been going through different post to see how i can use JPA component
to invole named query with parameter. I know from documentation that we
need to add it to the registry. Right now i am stuck and not able tot find a
way to get the parameter to the registry. Below is the route i have. I need
help with the syntax to pass data to registry.
I am using Java DSL with Spring Configuration for loading my Routes. I am
using Camel 2.18.2
from("jetty:{{server.api.endpoint}}/file_monitor/ui/profile/delete?httpMethodRestrict=DELETE")
.setHeader(Exchange.CONTENT_TYPE,
constant("application/json")).onException(Throwable.class).handled(true).process(genericExceptionHandler)
.end().validate(header(HeaderConstant.CLIENT_ID).isNotNull()).validate(header(HeaderConstant.FILE_NAME_PATTERN).isNotNull())
.process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
Integer clientId =
exchange.getIn().getHeader(HeaderConstant.CLIENT_ID, Integer.class);
String fileNamPattern =
exchange.getIn().getHeader(HeaderConstant.FILE_NAME_PATTERN, String.class);
FileProfilePK deleteEntity = new FileProfilePK(clientId,
fileNamPattern);
SimpleRegistry registry = new SimpleRegistry();
Map<String, Object> params = new HashMap<String,
Object>();
params.put("delete_entity", deleteEntity);
registry.put("params", params);
exchange.getIn().setBody(deleteEntity,
FileProfilePK.class);
}
}).to("jpa://deleteProfileId?consumer.namedQuery=deleteFileProfile&consumer.parameters=#params").marshal().json(JsonLibrary.Jackson);
In the entity class, the named Query is defined as -
@NamedQueries({ @NamedQuery(name = "deleteFileProfile", query = "DELETE from
FileProfileEntity fpe WHERE fpe.fileProfilePk = :delete_entity") })
Thanks
Sumit
--
View this message in context:
http://camel.465427.n5.nabble.com/Camel-JPA-Name-Query-with-Parameters-tp5795279.html
Sent from the Camel - Users mailing list archive at Nabble.com.