The following subsections describe how you can access Hazelcast map objects and perform queries on them.
The SQL service exposes
IMap objects as tables in the predefined
schema using exact names. This schema is in the SQL service search path so that
you can access the
IMap objects with or without the schema name.
Schema and table names are case-sensitive; you can access the
employee map, for example,
partitioned.employee, but not as
SELECT * FROM employee SELECT * FROM partitioned.employee
The SQL service resolves fields accessible from the SQL automatically. The
service reads the first local entry pair of the
IMap to construct the
list of fields. If the
IMap does not have local entries on the member where
the query is started, then the list of fields cannot be resolved, and an
exception is thrown.
Field names are case-sensitive.
IMap entry consists of a key and a value. These are accessible
this aliases. The following query returns
the keys and values of all entries in a map:
SELECT __key, this FROM employee
You may also access the nested fields of a key or a value. The list of exposed fields depends on the serialization format, as described below:
For Java objects (
IdentifiedDataSerializable), the object is deserialized if needed and then analyzed using the reflection mechanism. Only public fields and getters are taken into account. A public field is exposed using its exact name. A getter is exposed using the JavaBean naming conventions.
Portableobjects, the fields that are written in the
Portable.writePortablemethod are exposed using their exact names.
|You cannot query JSON fields in SQL. If you want to query JSON, see Querying JSON Strings.|
Employee class from the example above; the SQL service can access
the following fields:
Together with the key and value objects, you may query the following fields from
SELECT __key, this, name, age FROM employee
If both the key and value have fields with the same name, then the field of the value is exposed.
You may use the
SELECT * FROM <table> syntax to get all the table fields.
this fields are returned by the
SELECT * queries if they do not
have nested fields. For
IMap<Long, Employee>, the following query does
not return the
this field, because the value has nested fields
-- Returns __key, name, age SELECT * FROM employee
The SQL service can use
IMap indexes to speed up the execution of certain queries.
HASH indexes are supported.
See the Indexing Queries section for more information on
You can query the
IMap objects with
InMemoryFormat.NATIVE if they have
at least one index.
See Configuring with System Properties for more information on setting system properties.