Fuse 6 is no longer supported
As of February 2025, Red Hat Fuse 6 is no longer supported. If you are using Fuse 6, please upgrade to Red Hat build of Apache Camel.Este conteúdo não está disponível no idioma selecionado.
Chapter 20. JoSQL
Overview Copiar o linkLink copiado para a área de transferência!
Copiar o linkLink copiado para a área de transferência!
				The JoSQL (SQL for Java objects) language enables you to evaluate predicates and expressions in Apache Camel. JoSQL employs a SQL-like query syntax to perform selection and ordering operations on data from in-memory Java objects—however, JoSQL is not a database. In the JoSQL syntax, each Java object instance is treated like a table row and each object method is treated like a column name. Using this syntax, it is possible to construct powerful statements for extracting and compiling data from collections of Java objects. For details, see http://josql.sourceforge.net/.
			
Adding the JoSQL module Copiar o linkLink copiado para a área de transferência!
Copiar o linkLink copiado para a área de transferência!
				To use JoSQL in your routes you need to add a dependency on 
camel-josql to your project as shown in Example 20.1, “Adding the camel-josql dependency”.
			Example 20.1. Adding the camel-josql dependency
Static import Copiar o linkLink copiado para a área de transferência!
Copiar o linkLink copiado para a área de transferência!
				To use the 
sql() static method in your application code, include the following import statement in your Java source files:
			import static org.apache.camel.builder.sql.SqlBuilder.sql;
import static org.apache.camel.builder.sql.SqlBuilder.sql;
Variables Copiar o linkLink copiado para a área de transferência!
Copiar o linkLink copiado para a área de transferência!
				Table 20.1, “SQL variables” lists the variables that are accessible when using JoSQL.
			
| Name | Type | Description | 
|---|---|---|
exchange | org.apache.camel.Exchange | The current Exchange | 
in | org.apache.camel.Message | The IN message | 
out | org.apache.camel.Message | The OUT message | 
| property | Object | the Exchange property whose key is property | 
| header | Object | the IN message header whose key is header | 
| variable | Object | the variable whose key is variable | 
Example Copiar o linkLink copiado para a área de transferência!
Copiar o linkLink copiado para a área de transferência!
				Example 20.2, “Route using JoSQL” shows a route that uses JoSQL.
			
Example 20.2. Route using JoSQL