Hi,

I use Camel 3.4 and have a question regarding the JPA component.

I have the following query:
SELECT c FROM " + MyEntity.class.getName() + " c WHERE c.dummy = :myParam

I have been trying to get the following configuration to work (using Endpoint 
DSL):
.toD(jpa(MyEntity.class.getName()).query("SELECT c FROM " + 
MyEntity.class.getName() + " c WHERE c.dummy = ${headers.myParam}"))

But then I get the following Exception:
org.hibernate.QueryException: unexpected char: '{' [SELECT c FROM 
se.test.MyEntity c WHERE c.dummy = ${headers.myParam}]

While googling, I have seen someone claim that the configuration above should 
work. Is this something that works in later versions of Camel or is it a dead 
end?

I have been able to make the query work with the following solution:
.process(exchange -> {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("myParam", exchange.getIn().getHeader("myParam"));
        exchange.getIn().setHeader(JpaConstants.JPA_PARAMETERS_HEADER, map);
})
.to(jpa(MyEntity.class.getName()).query("SELECT c FROM " + 
MyEntity.class.getName() + " c WHERE c.dummy = :myParam"))

Could this be solved in a more elegant way?

Thanks in advance,
Calle

Reply via email to