org.axonframework.saga.repository.jdbc
Class GenericSagaSqlSchema

java.lang.Object
  extended by org.axonframework.saga.repository.jdbc.GenericSagaSqlSchema
All Implemented Interfaces:
SagaSqlSchema
Direct Known Subclasses:
HsqlSagaSqlSchema, PostgresSagaSqlSchema

public class GenericSagaSqlSchema
extends Object
implements SagaSqlSchema

Generic SagaSqlSchema implementation, for use in most databases. This implementation can be overridden to account for differences in dialect between database implementations.

Since:
2.2
Author:
Kristian Rosenvold, Allard Buijze

Field Summary
protected  SchemaConfiguration schemaConfiguration
           
 
Constructor Summary
GenericSagaSqlSchema()
          Initialize a GenericSagaSqlSchema using default settings.
GenericSagaSqlSchema(SchemaConfiguration schemaConfiguration)
          Initialize a GenericSagaSqlSchema.
 
Method Summary
 SerializedObject<byte[]> readSerializedSaga(ResultSet resultSet)
          Reads a SerializedObject from the given resultSet, which has been returned by executing the Statement returned from SagaSqlSchema.sql_loadSaga(java.sql.Connection, String)

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

 PreparedStatement sql_createTableAssocValueEntry(Connection conn)
          Creates a PreparedStatement that creates the table for storing Association Values for Sagas.
 PreparedStatement sql_createTableSagaEntry(Connection conn)
          Creates a PreparedStatement that creates the table for storing Sagas.
 PreparedStatement sql_deleteAssociationEntries(Connection connection, String sagaIdentifier)
          Creates a PreparedStatement that deletes all association entries for a Saga with given sagaIdentifier.
 PreparedStatement sql_deleteSagaEntry(Connection connection, String sagaIdentifier)
          Creates a PreparedStatement that deletes a Saga with given sagaIdentifier.
 PreparedStatement sql_findAssocSagaIdentifiers(Connection connection, String key, String value, String sagaType)
          Creates a PreparedStatement that finds identifiers of Sagas of given sagaType associated with the given association key and value.
 PreparedStatement sql_loadSaga(Connection connection, String sagaId)
          Creates a PreparedStatement that loads a single Saga, with given sagaId.
 PreparedStatement sql_removeAssocValue(Connection connection, String key, String value, String sagaType, String sagaIdentifier)
          Creates a PreparedStatement that removes an association value for given sagaIdentifier, where the association is identified with given key and value.
 PreparedStatement sql_storeAssocValue(Connection connection, String key, String value, String sagaType, String sagaIdentifier)
          Creates a PreparedStatement that stores an association with given key and value, for a Saga of given type and identifier.
 PreparedStatement sql_storeSaga(Connection connection, String sagaIdentifier, String revision, String sagaType, byte[] serializedSaga)
          Creates a PreparedStatement that inserts a Saga entry, of given sagaType and with given sagaIdentifier.
 PreparedStatement sql_updateSaga(Connection connection, String sagaIdentifier, byte[] serializedSaga, String sagaType, String revision)
          Creates a PreparedStatement that updates the serialized form of an existing Saga entry, of given sagaType and with given sagaIdentifier.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

schemaConfiguration

protected final SchemaConfiguration schemaConfiguration
Constructor Detail

GenericSagaSqlSchema

public GenericSagaSqlSchema()
Initialize a GenericSagaSqlSchema using default settings.


GenericSagaSqlSchema

public GenericSagaSqlSchema(SchemaConfiguration schemaConfiguration)
Initialize a GenericSagaSqlSchema.

Serialized data is stored using the given SchemaConfiguration.

Parameters:
schemaConfiguration -
Method Detail

sql_loadSaga

public PreparedStatement sql_loadSaga(Connection connection,
                                      String sagaId)
                               throws SQLException
Description copied from interface: SagaSqlSchema
Creates a PreparedStatement that loads a single Saga, with given sagaId.

Specified by:
sql_loadSaga in interface SagaSqlSchema
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 SagaSqlSchema.readSerializedSaga(java.sql.ResultSet), when executed
Throws:
SQLException - when an error occurs creating the PreparedStatement

sql_removeAssocValue

public PreparedStatement sql_removeAssocValue(Connection connection,
                                              String key,
                                              String value,
                                              String sagaType,
                                              String sagaIdentifier)
                                       throws SQLException
Description copied from interface: SagaSqlSchema
Creates a PreparedStatement that removes an association value for given sagaIdentifier, where the association is identified with given key and value.

Specified by:
sql_removeAssocValue in interface SagaSqlSchema
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

public PreparedStatement sql_storeAssocValue(Connection connection,
                                             String key,
                                             String value,
                                             String sagaType,
                                             String sagaIdentifier)
                                      throws SQLException
Description copied from interface: SagaSqlSchema
Creates a PreparedStatement that stores an association with given key and value, for a Saga of given type and identifier.

Specified by:
sql_storeAssocValue in interface SagaSqlSchema
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

public PreparedStatement sql_findAssocSagaIdentifiers(Connection connection,
                                                      String key,
                                                      String value,
                                                      String sagaType)
                                               throws SQLException
Description copied from interface: SagaSqlSchema
Creates a PreparedStatement that finds identifiers of Sagas of given sagaType associated with the given association key and value.

Specified by:
sql_findAssocSagaIdentifiers in interface SagaSqlSchema
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_deleteSagaEntry

public PreparedStatement sql_deleteSagaEntry(Connection connection,
                                             String sagaIdentifier)
                                      throws SQLException
Description copied from interface: SagaSqlSchema
Creates a PreparedStatement that deletes a Saga with given sagaIdentifier.

Specified by:
sql_deleteSagaEntry in interface SagaSqlSchema
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

public PreparedStatement sql_deleteAssociationEntries(Connection connection,
                                                      String sagaIdentifier)
                                               throws SQLException
Description copied from interface: SagaSqlSchema
Creates a PreparedStatement that deletes all association entries for a Saga with given sagaIdentifier.

Specified by:
sql_deleteAssociationEntries in interface SagaSqlSchema
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

public PreparedStatement sql_updateSaga(Connection connection,
                                        String sagaIdentifier,
                                        byte[] serializedSaga,
                                        String sagaType,
                                        String revision)
                                 throws SQLException
Description copied from interface: SagaSqlSchema
Creates a PreparedStatement that updates the serialized form of an existing Saga entry, of given sagaType and with given sagaIdentifier.

Specified by:
sql_updateSaga in interface SagaSqlSchema
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

public PreparedStatement sql_storeSaga(Connection connection,
                                       String sagaIdentifier,
                                       String revision,
                                       String sagaType,
                                       byte[] serializedSaga)
                                throws SQLException
Description copied from interface: SagaSqlSchema
Creates a PreparedStatement that inserts a Saga entry, of given sagaType and with given sagaIdentifier.

Specified by:
sql_storeSaga in interface SagaSqlSchema
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

public PreparedStatement sql_createTableAssocValueEntry(Connection conn)
                                                 throws SQLException
Description copied from interface: SagaSqlSchema
Creates a PreparedStatement that creates the table for storing Association Values for Sagas.

Specified by:
sql_createTableAssocValueEntry in interface SagaSqlSchema
Parameters:
conn - 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

public PreparedStatement sql_createTableSagaEntry(Connection conn)
                                           throws SQLException
Description copied from interface: SagaSqlSchema
Creates a PreparedStatement that creates the table for storing Sagas.

Specified by:
sql_createTableSagaEntry in interface SagaSqlSchema
Parameters:
conn - 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

public SerializedObject<byte[]> readSerializedSaga(ResultSet resultSet)
                                            throws SQLException
Description copied from interface: SagaSqlSchema
Reads a SerializedObject from the given resultSet, which has been returned by executing the Statement returned from SagaSqlSchema.sql_loadSaga(java.sql.Connection, String)

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

Specified by:
readSerializedSaga in interface SagaSqlSchema
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


Copyright © 2010-2016. All Rights Reserved.