Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The parameters to the SQL queries are named parameters in the elsql mapping files, and maps to corresponding keys from the Camel message, in the given precedence:

1. Camel 2.16.1: from message body if Simple expression.

2. from message body if its a java.util.Map

...

3. from message headers

If a named parameter cannot be resolved, then an exception is thrown.

...

Code Block
languagejava
   from("direct:projects")
     .setHeader("lic", constant("ASF"))
     .setHeader("min", constant(123))
     .to("elsql:projects:com/foo/orders.elsql")

And the elsql mapping file

Code Block
@NAME(projects)
  SELECT *
  FROM projects
  WHERE license = :lic AND id > :min
  ORDER BY id

...

Code Block
languagejava
   from("direct:projects")
     .to("elsql:projects:com/foo/orders.elsql")

 

In from Camel 2.16.1 onwards you can use Simple expressions as well, which allows to use an OGNL like notation on the message body, where it assumes to have getLicense and getMinimum methods:

Code Block
@NAME(projects)
  SELECT *
  FROM projects
  WHERE license = :${body.license} AND id > :${body.minimum}
  ORDER BY id

Include Page
Endpoint See Also
Endpoint See Also