Interface HazelcastTemplate

All Superinterfaces:
org.eclipse.jnosql.mapping.keyvalue.KeyValueTemplate, jakarta.nosql.Template

public interface HazelcastTemplate extends org.eclipse.jnosql.mapping.keyvalue.KeyValueTemplate
A specialized KeyValueTemplate for Hazelcast, providing methods to execute queries using SQL-like expressions and predicates. This template facilitates querying key-value structures stored in a Hazelcast instance. It supports both SQL-like queries with named parameters and Hazelcast-specific predicates. Example usage:
 
 @Inject
 private HazelcastTemplate hazelcastTemplate;

 // Query using SQL-like syntax
 Collection<Movie> movies = hazelcastTemplate.sql("name = :name", Map.of("name", "Inception"));
 movies.forEach(System.out::println);

 // Query using Hazelcast Predicate
 Predicate<String, Movie> predicate = Predicates.equal("genre", "Sci-Fi");
 Collection<Movie> sciFiMovies = hazelcastTemplate.sql(predicate);
 sciFiMovies.forEach(System.out::println);
 
 
See Also:
  • KeyValueTemplate
  • Method Summary

    Modifier and Type
    Method
    Description
    <K, V> Collection<V>
    sql(com.hazelcast.query.Predicate<K,V> predicate)
    Executes a Hazelcast query using a Predicate.
    <T> Collection<T>
    sql(String query)
    Executes a Hazelcast query using SQL-like syntax.
    <T> Collection<T>
    sql(String query, Map<String,Object> params)
    Executes a Hazelcast query with named parameters.

    Methods inherited from interface org.eclipse.jnosql.mapping.keyvalue.KeyValueTemplate

    delete, delete, get, get, put, put, put, put

    Methods inherited from interface jakarta.nosql.Template

    delete, delete, find, insert, insert, insert, insert, select, update, update
  • Method Details

    • sql

      <T> Collection<T> sql(String query)
      Executes a Hazelcast query using SQL-like syntax. The query should follow Hazelcast's SQL-like query syntax for key-value stores.
      Type Parameters:
      T - the entity type
      Parameters:
      query - the SQL-like query string
      Returns:
      a collection of matching entities
      Throws:
      NullPointerException - if the query is null
    • sql

      <T> Collection<T> sql(String query, Map<String,Object> params)
      Executes a Hazelcast query with named parameters. Example usage:
       
       Collection<Movie> movies = hazelcastTemplate.sql("name = :name", Map.of("name", "The Matrix"));
       
       
      Type Parameters:
      T - the entity type
      Parameters:
      query - the SQL-like query string
      params - a map of named parameters to bind in the query
      Returns:
      a collection of matching entities
      Throws:
      NullPointerException - if the query or params are null
    • sql

      <K, V> Collection<V> sql(com.hazelcast.query.Predicate<K,V> predicate)
      Executes a Hazelcast query using a Predicate. The predicate-based approach is useful for filtering key-value pairs based on specific criteria.
      Type Parameters:
      K - the key type
      V - the value type
      Parameters:
      predicate - the Hazelcast predicate for filtering data
      Returns:
      a collection of values that match the predicate
      Throws:
      NullPointerException - if the predicate is null