Executes SQL and returns an SqlResult. Converts passed SQL string and parameter values into an SqlStatement object and invokes executeStatement.
SQL string. SQL string placeholder character is question mark(?
)
Parameter list. The parameter count must be equal to number of placeholders in the SQL string
Options that are affecting how the query is executed
Executes SQL and returns an SqlResult.
SQL statement object
Generated using TypeDoc
SQL Service of the client. You can use this service to execute SQL queries.
The service is in beta state. Behavior and API might change in future releases.
Overview
Hazelcast is able to execute distributed SQL queries over the following entities:
Querying an IMap
Every IMap instance is exposed as a table with the same name in the
partitioned
schema. Thepartitioned
schema is included into a default search path, therefore an IMap could be referenced in an SQL statement with or without the schema name.Column Resolution
Every table backed by an IMap has a set of columns that are resolved automatically. Column resolution uses IMap entries located on the member that initiates the query. The engine extracts columns from a key and a value and then merges them into a single column set. In case the key and the value have columns with the same name, the key takes precedence.
Columns are extracted from objects as follows(which happens on the server-side):
The whole key and value objects could be accessed through a special fields
__key
andthis
, respectively. If key (value) object has fields, then the whole key (value) field is exposed as a normal field. Otherwise the field is hidden. Hidden fields can be accessed directly, but are not returned bySELECT * FROM ...
queries.If the member that initiates a query doesn't have local entries for the given IMap, the query fails.
Consider the following key/value model using Portable classes:
This model will be resolved to the following table columns:
Consistency
Results returned from IMap query are weakly consistent:
Usage
When a query is executed, an SqlResult is returned. The returned result is an async iterable. It can also be iterated using SqlResult.next method. The result should be closed at the end to release server resources. Fetching the last page closes the result. The code snippet below demonstrates a typical usage pattern: