Interface OrientDBTemplate

All Superinterfaces:
org.eclipse.jnosql.mapping.document.DocumentTemplate, org.eclipse.jnosql.mapping.semistructured.SemiStructuredTemplate, jakarta.nosql.Template

public interface OrientDBTemplate extends org.eclipse.jnosql.mapping.document.DocumentTemplate
A specialized DocumentTemplate for OrientDB.

This template provides methods for executing native SQL queries, live queries, and queries with named parameters.

  • Method Summary

    Modifier and Type
    Method
    Description
    <T> void
    live(String query, OrientDBLiveCallback<T> callBacks, Object... params)
    Executes a live query in OrientDB using a SQL string.
    <T> void
    live(org.eclipse.jnosql.communication.semistructured.SelectQuery query, OrientDBLiveCallback<T> callBacks)
    Executes a live query in OrientDB.
    <T> Stream<T>
    sql(String query, Object... params)
    Executes a native OrientDB SQL query.
    <T> Stream<T>
    sql(String query, Map<String,Object> params)
    Executes a native OrientDB SQL query with named parameters.

    Methods inherited from interface org.eclipse.jnosql.mapping.semistructured.SemiStructuredTemplate

    count, count, count, delete, deleteAll, exists, findAll, prepare, prepare, query, query, select, selectCursor, selectOffSet, singleResult, singleResult, singleResult

    Methods inherited from interface jakarta.nosql.Template

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

    • sql

      <T> Stream<T> sql(String query, Object... params)
      Executes a native OrientDB SQL query. This method allows running SQL queries with positional parameters. Example usage:
       
       Stream<User> users = template.sql("SELECT FROM User WHERE age > ?", 30);
       
       
      Type Parameters:
      T - the expected result type
      Parameters:
      query - the SQL query string
      params - optional positional parameters for the query
      Returns:
      a stream of results matching the query
      Throws:
      NullPointerException - if the query or params are null
    • sql

      <T> Stream<T> sql(String query, Map<String,Object> params)
      Executes a native OrientDB SQL query with named parameters. Example usage:
       
       Map<String, Object> params = Map.of("age", 30);
       Stream<User> users = template.sql("SELECT FROM User WHERE age > :age", params);
       
       
      Type Parameters:
      T - the expected result type
      Parameters:
      query - the SQL query string
      params - a map of named parameters for the query
      Returns:
      a stream of results matching the query
      Throws:
      NullPointerException - if the query or params are null
    • live

      <T> void live(org.eclipse.jnosql.communication.semistructured.SelectQuery query, OrientDBLiveCallback<T> callBacks)
      Executes a live query in OrientDB. A live query listens for real-time changes in the database and triggers callbacks for each event that occurs (insert, update, delete). Example usage:
       
       template.live(selectQuery, event -> System.out.println("Update: " + event));
       
       
      Type Parameters:
      T - the expected result type
      Parameters:
      query - the query definition using SelectQuery
      callBacks - callback to handle live query events
      Throws:
      NullPointerException - if either query or callBacks is null
    • live

      <T> void live(String query, OrientDBLiveCallback<T> callBacks, Object... params)
      Executes a live query in OrientDB using a SQL string. The query must include the "LIVE" keyword. Example usage:
       
       template.live("LIVE SELECT FROM User", event -> System.out.println("User changed: " + event));
       
       
      Type Parameters:
      T - the expected result type
      Parameters:
      query - the SQL query string containing the "LIVE" keyword
      callBacks - callback to handle live query events
      params - optional positional parameters for the query
      Throws:
      NullPointerException - if either query or callBacks is null