Interface SagaSqlSchema

All Known Implementing Classes:
GenericSagaSqlSchema, HsqlSagaSqlSchema, Oracle11SagaSqlSchema, PostgresSagaSqlSchema

public interface SagaSqlSchema
Interface describing the SQL statements that the JdbcSagaRepository needs to execute against the underlying database.
Since:
2.2
Author:
Kristian Rosenvold, Allard Buijze
  • Method Details

    • sql_loadSaga

      PreparedStatement sql_loadSaga(Connection connection, String sagaId) throws SQLException
      Creates a PreparedStatement that loads a single Saga, with given sagaId.
      Parameters:
      connection - The connection to create the PreparedStatement for
      sagaId - The identifier of the Saga to return
      Returns:
      a statement, that creates a result set to be processed by readSerializedSaga(java.sql.ResultSet), when executed
      Throws:
      SQLException - when an error occurs creating the PreparedStatement
    • sql_removeAssocValue

      PreparedStatement sql_removeAssocValue(Connection connection, String key, String value, String sagaType, String sagaIdentifier) throws SQLException
      Creates a PreparedStatement that removes an association value for given sagaIdentifier, where the association is identified with given key and value.
      Parameters:
      connection - The connection to create the PreparedStatement for
      key - The key of the association to remove
      value - The value of the association to remove
      sagaType - The type of saga to remove the association for
      sagaIdentifier - The identifier of the Saga to remove the association for
      Returns:
      a statement that removes the association value, when executed
      Throws:
      SQLException - when an error occurs creating the PreparedStatement
    • sql_storeAssocValue

      PreparedStatement sql_storeAssocValue(Connection connection, String key, String value, String sagaType, String sagaIdentifier) throws SQLException
      Creates a PreparedStatement that stores an association with given key and value, for a Saga of given type and identifier.
      Parameters:
      connection - The connection to create the PreparedStatement for
      key - The key of the association to store
      value - The value of the association to store
      sagaType - The type of saga to create the association for
      sagaIdentifier - The identifier of the Saga to create the association for
      Returns:
      a statement that inserts the association value, when executed
      Throws:
      SQLException - when an error occurs creating the PreparedStatement
    • sql_findAssocSagaIdentifiers

      PreparedStatement sql_findAssocSagaIdentifiers(Connection connection, String key, String value, String sagaType) throws SQLException
      Creates a PreparedStatement that finds identifiers of Sagas of given sagaType associated with the given association key and value.
      Parameters:
      connection - The connection to create the PreparedStatement for
      key - The key of the association
      value - The value of the association
      sagaType - The type of saga to find associations for
      Returns:
      a PreparedStatement that creates a ResultSet containing only saga identifiers when executed
      Throws:
      SQLException - when an error occurs creating the PreparedStatement
    • sql_findAssociations

      PreparedStatement sql_findAssociations(Connection connection, String sagaIdentifier, String sagaType) throws SQLException
      Creates a PreparedStatement that finds the associations of a Saga of given sagaType and given sagaIdentifier.
      Parameters:
      connection - The connection to create the PreparedStatement for
      sagaIdentifier - The identifier of the Saga
      sagaType - The type of saga to find associations for
      Returns:
      a PreparedStatement that creates a ResultSet containing association keys and their values
      Throws:
      SQLException - when an error occurs while creating the PreparedStatement
    • sql_deleteSagaEntry

      PreparedStatement sql_deleteSagaEntry(Connection connection, String sagaIdentifier) throws SQLException
      Creates a PreparedStatement that deletes a Saga with given sagaIdentifier.
      Parameters:
      connection - The connection to create the PreparedStatement for
      sagaIdentifier - The identifier of the Saga to remove
      Returns:
      a statement that deletes the Saga, when executed
      Throws:
      SQLException - when an error occurs creating the PreparedStatement
    • sql_deleteAssociationEntries

      PreparedStatement sql_deleteAssociationEntries(Connection connection, String sagaIdentifier) throws SQLException
      Creates a PreparedStatement that deletes all association entries for a Saga with given sagaIdentifier.
      Parameters:
      connection - The connection to create the PreparedStatement for
      sagaIdentifier - The identifier of the Saga to remove associations for
      Returns:
      a statement that deletes the associations, when executed
      Throws:
      SQLException - when an error occurs creating the PreparedStatement
    • sql_updateSaga

      PreparedStatement sql_updateSaga(Connection connection, String sagaIdentifier, byte[] serializedSaga, String sagaType, String revision) throws SQLException
      Creates a PreparedStatement that updates the serialized form of an existing Saga entry, of given sagaType and with given sagaIdentifier.
      Parameters:
      connection - The connection to create the PreparedStatement for
      sagaIdentifier - The identifier of the Saga to update
      serializedSaga - The serialized form of the saga to update
      sagaType - The serialized type of the saga
      revision - The revision identifier of the serialized form
      Returns:
      a statement that updates a Saga entry, when executed
      Throws:
      SQLException - when an error occurs creating the PreparedStatement
    • sql_storeSaga

      PreparedStatement sql_storeSaga(Connection connection, String sagaIdentifier, String revision, String sagaType, byte[] serializedSaga) throws SQLException
      Creates a PreparedStatement that inserts a Saga entry, of given sagaType and with given sagaIdentifier.
      Parameters:
      connection - The connection to create the PreparedStatement for
      sagaIdentifier - The identifier of the Saga to insert
      revision - The revision identifier of the serialized form
      sagaType - The serialized type of the saga
      serializedSaga - The serialized form of the saga to insert
      Returns:
      a statement that inserts a Saga entry, when executed
      Throws:
      SQLException - when an error occurs creating the PreparedStatement
    • sql_createTableAssocValueEntry

      PreparedStatement sql_createTableAssocValueEntry(Connection connection) throws SQLException
      Creates a PreparedStatement that creates the table for storing Association Values for Sagas.
      Parameters:
      connection - The connection to create the PreparedStatement for
      Returns:
      a Prepared statement that created the Association Value table, when executed
      Throws:
      SQLException - when an error occurs creating the PreparedStatement
    • sql_createTableSagaEntry

      PreparedStatement sql_createTableSagaEntry(Connection connection) throws SQLException
      Creates a PreparedStatement that creates the table for storing Sagas.
      Parameters:
      connection - The connection to create the PreparedStatement for
      Returns:
      a Prepared statement that created the Saga table, when executed
      Throws:
      SQLException - when an error occurs creating the PreparedStatement
    • readSerializedSaga

      SerializedObject<?> readSerializedSaga(ResultSet resultSet) throws SQLException
      Reads a SerializedObject from the given resultSet, which has been returned by executing the Statement returned from sql_loadSaga(java.sql.Connection, String)

      Note: The implementation must not change the resultSet's cursor position

      Parameters:
      resultSet - The result set to read data from.
      Returns:
      a SerializedObject, containing the serialized data from the resultSet
      Throws:
      SQLException - when an exception occurs reading from the resultSet
    • readAssociationValues

      Set<AssociationValue> readAssociationValues(ResultSet resultSet) throws SQLException
      Reads a Set of AssociationValues from the given resultSet, which has been returned by executing the Statement returned from sql_findAssociations(Connection, String, String).
      Parameters:
      resultSet - The result set to read data from.
      Returns:
      a Set of AssociationValues from the resultSet
      Throws:
      SQLException - when an exception occurs reading from the resultSet
    • readToken

      String readToken(ResultSet resultSet)
      Reads a token from the given resultSet.
      Parameters:
      resultSet - The result set to read data from.
      Returns:
      the token from the resultSet
      Throws:
      SQLException - when an exception occurs reading from the resultSet