1

I'm trying to use the jpa component to select by id that i get from the header. I found an example in documentation that uses the native select query:

from("direct:query").to("jpa://org.apache.camel.examples.MultiSteps?query=
select o from org.apache.camel.examples.MultiSteps o where o.step = 1");

I tried to replace the "1" constant with ${header.id}:

from("direct:query").to("jpa://org.apache.camel.examples.MultiSteps?query=
select o from org.apache.camel.examples.MultiSteps o where o.step = ${header.id}");

It doesn't seem to work, i get:

org.hibernate.QueryException: unexpected char: '{'

Maybe there is another way to make that work?

Pashok
  • 167
  • 1
  • 8

1 Answers1

0

I managed to solve this, based on this question:

Just needed to use toD instead of to:

from("direct:query").toD("jpa://org.apache.camel.examples.MultiSteps?query=
select o from org.apache.camel.examples.MultiSteps o where o.step = ${header.id}");
Pashok
  • 167
  • 1
  • 8