org.axonframework.eventstore.jdbc
Interface EventSqlSchema<T>

Type Parameters:
T - The data type used to store serialized objects
All Known Implementing Classes:
GenericEventSqlSchema, PostgresEventSqlSchema

public interface EventSqlSchema<T>

Interface describing the operations that the JDBC Event Store needs to do on a backing database. This abstraction allows for different SQL dialects to be used in cases where the default doesn't suffice.

Since:
2.2
Author:
Kristian Rosenvold, Allard Buijze

Method Summary
 SerializedDomainEventData<T> createSerializedDomainEventData(ResultSet resultSet)
          Reads the current entry of the ResultSet into a SerializedDomainEventData.
 Class<T> getDataType()
          Returns the type used to store serialized payloads.
 PreparedStatement sql_createDomainEventEntryTable(Connection connection)
          Creates a PreparedStatement that allows for the creation of the table to store Event entries.
 PreparedStatement sql_createSnapshotEventEntryTable(Connection connection)
          Creates a PreparedStatement that allows for the creation of the table to store Snapshots.
 Object sql_dateTime(org.joda.time.DateTime input)
          Converts a DateTime to a data value suitable for the database scheme.
 PreparedStatement sql_fetchFromSequenceNumber(Connection connection, String type, Object aggregateIdentifier, long firstSequenceNumber)
          Creates a PreparedStatement that fetches event data for an aggregate with given type and identifier, starting at the given firstSequenceNumber.
 PreparedStatement sql_findSnapshotSequenceNumbers(Connection connection, String type, Object aggregateIdentifier)
          Creates a PreparedStatement that returns the sequence numbers of snapshots for an aggregate of given type and aggregateIdentifier.
 PreparedStatement sql_getFetchAll(Connection connection, String whereClause, Object[] parameters)
          Creates a PreparedStatement that fetches all event messages matching the given whereClause.
 PreparedStatement sql_insertDomainEventEntry(Connection connection, String eventIdentifier, String aggregateIdentifier, long sequenceNumber, org.joda.time.DateTime timestamp, String eventType, String eventRevision, T eventPayload, T eventMetaData, String aggregateType)
          Creates the PreparedStatement for inserting a DomainEvent in the Event Store, using given attributes.
 PreparedStatement sql_insertSnapshotEventEntry(Connection connection, String eventIdentifier, String aggregateIdentifier, long sequenceNumber, org.joda.time.DateTime timestamp, String eventType, String eventRevision, T eventPayload, T eventMetaData, String aggregateType)
          Creates the PreparedStatement for inserting a Snapshot Event in the Event Store, using given attributes.
 PreparedStatement sql_loadLastSnapshot(Connection connection, Object identifier, String aggregateType)
          Creates the PreparedStatement for loading the last snapshot event for an aggregate with given identifier and of given aggregateType.
 PreparedStatement sql_pruneSnapshots(Connection connection, String type, Object aggregateIdentifier, long sequenceOfFirstSnapshotToPrune)
          Creates a PreparedStatement that deletes all snapshots with a sequence identifier equal or lower to the given sequenceOfFirstSnapshotToPrune, for an aggregate of given type and aggregateIdentifier.
 

Method Detail

sql_loadLastSnapshot

PreparedStatement sql_loadLastSnapshot(Connection connection,
                                       Object identifier,
                                       String aggregateType)
                                       throws SQLException
Creates the PreparedStatement for loading the last snapshot event for an aggregate with given identifier and of given aggregateType.

Parameters:
connection - The connection to create the PreparedStatement for
identifier - The identifier of the aggregate to find the snapshot for
aggregateType - The type identifier of the aggregate
Returns:
a PreparedStatement with all parameters set
Throws:
SQLException - when an exception occurs while creating the prepared statement

sql_insertDomainEventEntry

PreparedStatement sql_insertDomainEventEntry(Connection connection,
                                             String eventIdentifier,
                                             String aggregateIdentifier,
                                             long sequenceNumber,
                                             org.joda.time.DateTime timestamp,
                                             String eventType,
                                             String eventRevision,
                                             T eventPayload,
                                             T eventMetaData,
                                             String aggregateType)
                                             throws SQLException
Creates the PreparedStatement for inserting a DomainEvent in the Event Store, using given attributes.

Parameters:
connection - The connection to create the PreparedStatement for
eventIdentifier - The unique identifier of the event
aggregateIdentifier - The identifier of the aggregate that generated the event
sequenceNumber - The sequence number of the event
timestamp - The time at which the Event Message was generated
eventType - The type identifier of the serialized event
eventRevision - The revision of the serialized event
eventPayload - The serialized payload of the Event
eventMetaData - The serialized meta data of the event
aggregateType - The type identifier of the aggregate the event belongs to
Returns:
a PreparedStatement with all parameters set
Throws:
SQLException - when an exception occurs while creating the prepared statement

sql_insertSnapshotEventEntry

PreparedStatement sql_insertSnapshotEventEntry(Connection connection,
                                               String eventIdentifier,
                                               String aggregateIdentifier,
                                               long sequenceNumber,
                                               org.joda.time.DateTime timestamp,
                                               String eventType,
                                               String eventRevision,
                                               T eventPayload,
                                               T eventMetaData,
                                               String aggregateType)
                                               throws SQLException
Creates the PreparedStatement for inserting a Snapshot Event in the Event Store, using given attributes.

Parameters:
connection - The connection to create the PreparedStatement for
eventIdentifier - The unique identifier of the event
aggregateIdentifier - The identifier of the aggregate that generated the event
sequenceNumber - The sequence number of the event
timestamp - The time at which the Event Message was generated
eventType - The type identifier of the serialized event
eventRevision - The revision of the serialized event
eventPayload - The serialized payload of the Event
eventMetaData - The serialized meta data of the event
aggregateType - The type identifier of the aggregate the event belongs to
Returns:
a PreparedStatement with all parameters set
Throws:
SQLException - when an exception occurs while creating the prepared statement

sql_pruneSnapshots

PreparedStatement sql_pruneSnapshots(Connection connection,
                                     String type,
                                     Object aggregateIdentifier,
                                     long sequenceOfFirstSnapshotToPrune)
                                     throws SQLException
Creates a PreparedStatement that deletes all snapshots with a sequence identifier equal or lower to the given sequenceOfFirstSnapshotToPrune, for an aggregate of given type and aggregateIdentifier.

Parameters:
connection - The connection to create the PreparedStatement for
type - The type identifier of the aggregate
aggregateIdentifier - The identifier of the aggregate
sequenceOfFirstSnapshotToPrune - The sequence number of the most recent snapshot to prune
Returns:
The PreparedStatement, ready to execute
Throws:
SQLException - when an exception occurs while creating the prepared statement

sql_findSnapshotSequenceNumbers

PreparedStatement sql_findSnapshotSequenceNumbers(Connection connection,
                                                  String type,
                                                  Object aggregateIdentifier)
                                                  throws SQLException
Creates a PreparedStatement that returns the sequence numbers of snapshots for an aggregate of given type and aggregateIdentifier.

Parameters:
connection - The connection to create the PreparedStatement for
type - The type identifier of the aggregate
aggregateIdentifier - The identifier of the aggregate
Returns:
The PreparedStatement, ready to execute, returning a single column with longs.
Throws:
SQLException - when an exception occurs while creating the prepared statement

sql_fetchFromSequenceNumber

PreparedStatement sql_fetchFromSequenceNumber(Connection connection,
                                              String type,
                                              Object aggregateIdentifier,
                                              long firstSequenceNumber)
                                              throws SQLException
Creates a PreparedStatement that fetches event data for an aggregate with given type and identifier, starting at the given firstSequenceNumber.

Parameters:
connection - The connection to create the PreparedStatement for
type - The type identifier of the aggregate
aggregateIdentifier - The identifier of the aggregate
firstSequenceNumber - The sequence number of the first event to return
Returns:
a PreparedStatement that returns columns that can be converted using createSerializedDomainEventData(java.sql.ResultSet)
Throws:
SQLException - when an exception occurs while creating the prepared statement

sql_getFetchAll

PreparedStatement sql_getFetchAll(Connection connection,
                                  String whereClause,
                                  Object[] parameters)
                                  throws SQLException
Creates a PreparedStatement that fetches all event messages matching the given whereClause. The given parameters provide the parameters used in the where clause, in the order of declaration.

Parameters:
connection - The connection to create the PreparedStatement for
whereClause - The SQL snippet to use after the WHERE directive. May be null or an empty String to indicate that no filter is to be applied
parameters - The parameters to set in the WHERE clause
Returns:
a PreparedStatement that returns columns that can be converted using createSerializedDomainEventData(java.sql.ResultSet)
Throws:
SQLException - when an exception occurs while creating the prepared statement

sql_createSnapshotEventEntryTable

PreparedStatement sql_createSnapshotEventEntryTable(Connection connection)
                                                    throws SQLException
Creates a PreparedStatement that allows for the creation of the table to store Snapshots.

Parameters:
connection - The connection to create the PreparedStatement for
Returns:
The Prepared Statement, ready to be executed
Throws:
SQLException - when an exception occurs while creating the prepared statement

sql_createDomainEventEntryTable

PreparedStatement sql_createDomainEventEntryTable(Connection connection)
                                                  throws SQLException
Creates a PreparedStatement that allows for the creation of the table to store Event entries.

Parameters:
connection - The connection to create the PreparedStatement for
Returns:
The Prepared Statement, ready to be executed
Throws:
SQLException - when an exception occurs while creating the prepared statement

createSerializedDomainEventData

SerializedDomainEventData<T> createSerializedDomainEventData(ResultSet resultSet)
                                                             throws SQLException
Reads the current entry of the ResultSet into a SerializedDomainEventData.

Note: the implementation *must* not change the ResultSet's cursor position.

Parameters:
resultSet - The result set returned from executing one of the Prepared Statements declared on this interface
Returns:
a single SerializedDomainEventData instance
Throws:
SQLException - when an exception occurs while creating the prepared statement
See Also:
SimpleSerializedDomainEventData

sql_dateTime

Object sql_dateTime(org.joda.time.DateTime input)
Converts a DateTime to a data value suitable for the database scheme.

Parameters:
input - DateTime to convert
Returns:
data representing the date time suitable for the current SQL scheme

getDataType

Class<T> getDataType()
Returns the type used to store serialized payloads.

Returns:
the type used to store serialized payloads


Copyright © 2010-2016. All Rights Reserved.