Class GenericSagaSqlSchema
java.lang.Object
org.axonframework.modelling.saga.repository.jdbc.GenericSagaSqlSchema
- All Implemented Interfaces:
SagaSqlSchema
- Direct Known Subclasses:
HsqlSagaSqlSchema,Oracle11SagaSqlSchema,PostgresSagaSqlSchema
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
Fields -
Constructor Summary
ConstructorsConstructorDescriptionInitialize a GenericSagaSqlSchema using default settings.GenericSagaSqlSchema(SagaSchema sagaSchema) Initialize a GenericSagaSqlSchema. -
Method Summary
Modifier and TypeMethodDescriptionreadAssociationValues(ResultSet resultSet) Reads a Set of AssociationValues from the givenresultSet, which has been returned by executing the Statement returned fromSagaSqlSchema.sql_findAssociations(Connection, String, String).SerializedObject<byte[]> readSerializedSaga(ResultSet resultSet) Reads a SerializedObject from the givenresultSet, which has been returned by executing the Statement returned fromSagaSqlSchema.sql_loadSaga(java.sql.Connection, String)Reads a token from the givenresultSet.Returns theSagaSchemaused to configure this sql saga schema.Creates a PreparedStatement that creates the table for storing Association Values for Sagas.Creates a PreparedStatement that creates the table for storing Sagas.sql_deleteAssociationEntries(Connection connection, String sagaIdentifier) Creates a PreparedStatement that deletes all association entries for a Saga with givensagaIdentifier.sql_deleteSagaEntry(Connection connection, String sagaIdentifier) Creates a PreparedStatement that deletes a Saga with givensagaIdentifier.sql_findAssociations(Connection connection, String sagaIdentifier, String sagaType) Creates a PreparedStatement that finds the associations of a Saga of givensagaTypeand givensagaIdentifier.sql_findAssocSagaIdentifiers(Connection connection, String key, String value, String sagaType) Creates a PreparedStatement that finds identifiers of Sagas of givensagaTypeassociated with the given associationkeyandvalue.sql_loadSaga(Connection connection, String sagaId) Creates a PreparedStatement that loads a single Saga, with givensagaId.sql_removeAssocValue(Connection connection, String key, String value, String sagaType, String sagaIdentifier) Creates a PreparedStatement that removes an association value for givensagaIdentifier, where the association is identified with givenkeyandvalue.sql_storeAssocValue(Connection connection, String key, String value, String sagaType, String sagaIdentifier) Creates a PreparedStatement that stores an association with givenkeyandvalue, for a Saga of giventypeandidentifier.sql_storeSaga(Connection connection, String sagaIdentifier, String revision, String sagaType, byte[] serializedSaga) Creates a PreparedStatement that inserts a Saga entry, of givensagaTypeand with givensagaIdentifier.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 givensagaTypeand with givensagaIdentifier.
-
Field Details
-
sagaSchema
-
-
Constructor Details
-
GenericSagaSqlSchema
public GenericSagaSqlSchema()Initialize a GenericSagaSqlSchema using default settings. -
GenericSagaSqlSchema
Initialize a GenericSagaSqlSchema. Serialized data is stored using the givensagaSchema.- Parameters:
sagaSchema- The configuration to use for the initialization of the schema
-
-
Method Details
-
sql_loadSaga
Description copied from interface:SagaSqlSchemaCreates a PreparedStatement that loads a single Saga, with givensagaId.- Specified by:
sql_loadSagain interfaceSagaSqlSchema- Parameters:
connection- The connection to create the PreparedStatement forsagaId- 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:SagaSqlSchemaCreates a PreparedStatement that removes an association value for givensagaIdentifier, where the association is identified with givenkeyandvalue.- Specified by:
sql_removeAssocValuein interfaceSagaSqlSchema- Parameters:
connection- The connection to create the PreparedStatement forkey- The key of the association to removevalue- The value of the association to removesagaType- The type of saga to remove the association forsagaIdentifier- 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:SagaSqlSchemaCreates a PreparedStatement that stores an association with givenkeyandvalue, for a Saga of giventypeandidentifier.- Specified by:
sql_storeAssocValuein interfaceSagaSqlSchema- Parameters:
connection- The connection to create the PreparedStatement forkey- The key of the association to storevalue- The value of the association to storesagaType- The type of saga to create the association forsagaIdentifier- 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:SagaSqlSchemaCreates a PreparedStatement that finds identifiers of Sagas of givensagaTypeassociated with the given associationkeyandvalue.- Specified by:
sql_findAssocSagaIdentifiersin interfaceSagaSqlSchema- Parameters:
connection- The connection to create the PreparedStatement forkey- The key of the associationvalue- The value of the associationsagaType- 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
public PreparedStatement sql_findAssociations(Connection connection, String sagaIdentifier, String sagaType) throws SQLException Description copied from interface:SagaSqlSchemaCreates a PreparedStatement that finds the associations of a Saga of givensagaTypeand givensagaIdentifier.- Specified by:
sql_findAssociationsin interfaceSagaSqlSchema- Parameters:
connection- The connection to create the PreparedStatement forsagaIdentifier- The identifier of the SagasagaType- 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
-
readToken
Description copied from interface:SagaSqlSchemaReads a token from the givenresultSet.- Specified by:
readTokenin interfaceSagaSqlSchema- Parameters:
resultSet- The result set to read data from.- Returns:
- the token from the resultSet
-
readAssociationValues
Description copied from interface:SagaSqlSchemaReads a Set of AssociationValues from the givenresultSet, which has been returned by executing the Statement returned fromSagaSqlSchema.sql_findAssociations(Connection, String, String).- Specified by:
readAssociationValuesin interfaceSagaSqlSchema- 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
-
sql_deleteSagaEntry
public PreparedStatement sql_deleteSagaEntry(Connection connection, String sagaIdentifier) throws SQLException Description copied from interface:SagaSqlSchemaCreates a PreparedStatement that deletes a Saga with givensagaIdentifier.- Specified by:
sql_deleteSagaEntryin interfaceSagaSqlSchema- Parameters:
connection- The connection to create the PreparedStatement forsagaIdentifier- 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:SagaSqlSchemaCreates a PreparedStatement that deletes all association entries for a Saga with givensagaIdentifier.- Specified by:
sql_deleteAssociationEntriesin interfaceSagaSqlSchema- Parameters:
connection- The connection to create the PreparedStatement forsagaIdentifier- 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:SagaSqlSchemaCreates a PreparedStatement that updates the serialized form of an existing Saga entry, of givensagaTypeand with givensagaIdentifier.- Specified by:
sql_updateSagain interfaceSagaSqlSchema- Parameters:
connection- The connection to create the PreparedStatement forsagaIdentifier- The identifier of the Saga to updateserializedSaga- The serialized form of the saga to updatesagaType- The serialized type of the sagarevision- 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:SagaSqlSchemaCreates a PreparedStatement that inserts a Saga entry, of givensagaTypeand with givensagaIdentifier.- Specified by:
sql_storeSagain interfaceSagaSqlSchema- Parameters:
connection- The connection to create the PreparedStatement forsagaIdentifier- The identifier of the Saga to insertrevision- The revision identifier of the serialized formsagaType- The serialized type of the sagaserializedSaga- 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
Description copied from interface:SagaSqlSchemaCreates a PreparedStatement that creates the table for storing Association Values for Sagas.- Specified by:
sql_createTableAssocValueEntryin interfaceSagaSqlSchema- 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
Description copied from interface:SagaSqlSchemaCreates a PreparedStatement that creates the table for storing Sagas.- Specified by:
sql_createTableSagaEntryin interfaceSagaSqlSchema- 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
Description copied from interface:SagaSqlSchemaReads a SerializedObject from the givenresultSet, which has been returned by executing the Statement returned fromSagaSqlSchema.sql_loadSaga(java.sql.Connection, String)Note: The implementation must not change the resultSet's cursor position- Specified by:
readSerializedSagain interfaceSagaSqlSchema- 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
-
sagaSchema
Returns theSagaSchemaused to configure this sql saga schema.- Returns:
- the saga schema
-