Interface SQLRecordTransformer<K,​V>


  • public interface SQLRecordTransformer<K,​V>
    Interface for transforming between Infinispan entries (key / value pair and metadata) and a corresponding SQL record. Implementations must be thread-safe.

    To specify an entry transformer for a given Infinispan cache that is backed by an SQL store, provide its class name to the store configuration.

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      java.lang.String getCreateTableStatement()
      Returns the SQL statement to create a table for the entries.
      java.lang.String getTableName()
      Returns the associated SQL table name.
      void init​(SQLRecordTransformer.InitParameters initParams)
      Initialises the SQL transformer.
      java.util.Collection<org.jooq.Condition> resolveSelectionConditions​(K key)
      Resolves the SQL selection conditions for the specified Infinispan entry key.
      com.nimbusds.infinispan.persistence.common.InfinispanEntry<K,​V> toInfinispanEntry​(org.jooq.Record sqlRecord)
      Transforms the specified SQL record to an Infinispan entry (key / value / metadata triple).
      SQLRecord toSQLRecord​(com.nimbusds.infinispan.persistence.common.InfinispanEntry<K,​V> infinispanEntry)
      Transforms the specified Infinispan entry (key / value pair with optional metadata) to an SQL record ready to be written.
    • Method Detail

      • getCreateTableStatement

        java.lang.String getCreateTableStatement()
        Returns the SQL statement to create a table for the entries. Typically required at SQL store startup if the underlying table doesn't exist yet. The statement must be aware of the SQL dialect of the configured database.
        Returns:
        The SQL create table statement.
      • getTableName

        java.lang.String getTableName()
        Returns the associated SQL table name.
        Returns:
        The table name.
      • resolveSelectionConditions

        java.util.Collection<org.jooq.Condition> resolveSelectionConditions​(K key)
        Resolves the SQL selection conditions for the specified Infinispan entry key.
        Parameters:
        key - The Infinispan entry key. Not null.
        Returns:
        One or more WHERE conditions.
      • toSQLRecord

        SQLRecord toSQLRecord​(com.nimbusds.infinispan.persistence.common.InfinispanEntry<K,​V> infinispanEntry)
        Transforms the specified Infinispan entry (key / value pair with optional metadata) to an SQL record ready to be written.

        Example:

        Infinispan entry:

        • Key: cae7t
        • Value: Java POJO with fields uid=cae7t, givenName=Alice, surname=Adams and [email protected].
        • Metadata: Specifies the entry expiration and other properties.

        Resulting SQL record:

         uid: cae7t (key)
         surname: Adams
         given_name: Alice
         email: [email protected]
         
        Parameters:
        infinispanEntry - The Infinispan entry. Not null.
        Returns:
        The SQL record.
      • toInfinispanEntry

        com.nimbusds.infinispan.persistence.common.InfinispanEntry<K,​VtoInfinispanEntry​(org.jooq.Record sqlRecord)
        Transforms the specified SQL record to an Infinispan entry (key / value / metadata triple).

        Example:

        SQL record:

         uid: cae7t
         surname: Adams
         given_name: Alice
         email: [email protected]
         

        Resulting Infinispan entry:

        • Key: cae7t
        • Value: Java POJO with fields uid=cae7t, givenName=Alice, surname=Adams and [email protected].
        • Metadata: Default metadata (no expiration, etc).
        Parameters:
        sqlRecord - The SQL record. Must not be null.
        Returns:
        The Infinispan entry (key / value pair with optional metadata).