T - The type used when storing serialized datapublic class GenericEventSqlSchema<T> extends Object implements EventSqlSchema<T>
| Constructor and Description |
|---|
GenericEventSqlSchema()
Initialize a GenericEventSqlSchema using default settings.
|
GenericEventSqlSchema(Class<T> dataType)
Initialize a GenericEventSqlSchema using default settings.
|
| Modifier and Type | Method and Description |
|---|---|
SerializedDomainEventData<T> |
createSerializedDomainEventData(ResultSet resultSet)
Reads the current entry of the ResultSet into a SerializedDomainEventData.
|
protected PreparedStatement |
doInsertEventEntry(String tableName,
Connection connection,
String eventIdentifier,
String aggregateIdentifier,
long sequenceNumber,
org.joda.time.DateTime timestamp,
String eventType,
String eventRevision,
T eventPayload,
T eventMetaData,
String aggregateType)
Creates a statement to insert an entry with given attributes in the given
tableName. |
Class<T> |
getDataType()
Returns the type used to store serialized payloads.
|
protected T |
readPayload(ResultSet resultSet,
int columnIndex)
Reads a serialized object from the given
resultSet at given columnIndex. |
protected Object |
readTimeStamp(ResultSet resultSet,
int columnIndex)
Reads a timestamp from the given
resultSet at given columnIndex. |
void |
setForceUtc(boolean forceUtc)
Control if date time in the SQL scheme
should use UTC time zone or system local time zone.
|
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.
|
String |
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[] params)
Creates a PreparedStatement that fetches all event messages matching the given
whereClause. |
PreparedStatement |
sql_insertDomainEventEntry(Connection conn,
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 conn,
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. |
public GenericEventSqlSchema()
public void setForceUtc(boolean forceUtc)
Default is to use system local time zone.
You should not change this after going into production, since it would affect the batching iterator when fetching events.
forceUtc - set true to force all date times to use UTC time zonepublic PreparedStatement sql_loadLastSnapshot(Connection connection, Object identifier, String aggregateType) throws SQLException
EventSqlSchemaidentifier and of given aggregateType.sql_loadLastSnapshot in interface EventSqlSchema<T>connection - The connection to create the PreparedStatement foridentifier - The identifier of the aggregate to find the snapshot foraggregateType - The type identifier of the aggregateSQLException - when an exception occurs while creating the prepared statementpublic PreparedStatement sql_insertDomainEventEntry(Connection conn, String eventIdentifier, String aggregateIdentifier, long sequenceNumber, org.joda.time.DateTime timestamp, String eventType, String eventRevision, T eventPayload, T eventMetaData, String aggregateType) throws SQLException
EventSqlSchemasql_insertDomainEventEntry in interface EventSqlSchema<T>conn - The connection to create the PreparedStatement foreventIdentifier - The unique identifier of the eventaggregateIdentifier - The identifier of the aggregate that generated the eventsequenceNumber - The sequence number of the eventtimestamp - The time at which the Event Message was generatedeventType - The type identifier of the serialized eventeventRevision - The revision of the serialized eventeventPayload - The serialized payload of the EventeventMetaData - The serialized meta data of the eventaggregateType - The type identifier of the aggregate the event belongs toSQLException - when an exception occurs while creating the prepared statementpublic PreparedStatement sql_insertSnapshotEventEntry(Connection conn, String eventIdentifier, String aggregateIdentifier, long sequenceNumber, org.joda.time.DateTime timestamp, String eventType, String eventRevision, T eventPayload, T eventMetaData, String aggregateType) throws SQLException
EventSqlSchemasql_insertSnapshotEventEntry in interface EventSqlSchema<T>conn - The connection to create the PreparedStatement foreventIdentifier - The unique identifier of the eventaggregateIdentifier - The identifier of the aggregate that generated the eventsequenceNumber - The sequence number of the eventtimestamp - The time at which the Event Message was generatedeventType - The type identifier of the serialized eventeventRevision - The revision of the serialized eventeventPayload - The serialized payload of the EventeventMetaData - The serialized meta data of the eventaggregateType - The type identifier of the aggregate the event belongs toSQLException - when an exception occurs while creating the prepared statementprotected PreparedStatement doInsertEventEntry(String tableName, 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
tableName. This method
is used by sql_insertDomainEventEntry(java.sql.Connection, String, String, long, org.joda.time.DateTime,
String, String, Object, Object, String) and sql_insertSnapshotEventEntry(java.sql.Connection, String,
String, long, org.joda.time.DateTime, String, String, Object, Object, String), and provides an easier way to
change to types of columns used.tableName - The name of the table to insert the entry intoconnection - The connection to create the statement foreventIdentifier - The unique identifier of the eventaggregateIdentifier - The identifier of the aggregate that generated the eventsequenceNumber - The sequence number of the eventtimestamp - The time at which the Event Message was generatedeventType - The type identifier of the serialized eventeventRevision - The revision of the serialized eventeventPayload - The serialized payload of the EventeventMetaData - The serialized meta data of the eventaggregateType - The type identifier of the aggregate the event belongs toSQLException - when an exception occurs creating the PreparedStatementpublic PreparedStatement sql_pruneSnapshots(Connection connection, String type, Object aggregateIdentifier, long sequenceOfFirstSnapshotToPrune) throws SQLException
EventSqlSchemasequenceOfFirstSnapshotToPrune, for an aggregate of given type and
aggregateIdentifier.sql_pruneSnapshots in interface EventSqlSchema<T>connection - The connection to create the PreparedStatement fortype - The type identifier of the aggregateaggregateIdentifier - The identifier of the aggregatesequenceOfFirstSnapshotToPrune - The sequence number of the most recent snapshot to pruneSQLException - when an exception occurs while creating the prepared statementpublic PreparedStatement sql_findSnapshotSequenceNumbers(Connection connection, String type, Object aggregateIdentifier) throws SQLException
EventSqlSchematype and aggregateIdentifier.sql_findSnapshotSequenceNumbers in interface EventSqlSchema<T>connection - The connection to create the PreparedStatement fortype - The type identifier of the aggregateaggregateIdentifier - The identifier of the aggregateSQLException - when an exception occurs while creating the prepared statementpublic PreparedStatement sql_fetchFromSequenceNumber(Connection connection, String type, Object aggregateIdentifier, long firstSequenceNumber) throws SQLException
EventSqlSchematype and
identifier, starting at the given firstSequenceNumber.sql_fetchFromSequenceNumber in interface EventSqlSchema<T>connection - The connection to create the PreparedStatement fortype - The type identifier of the aggregateaggregateIdentifier - The identifier of the aggregatefirstSequenceNumber - The sequence number of the first event to returnEventSqlSchema.createSerializedDomainEventData(java.sql.ResultSet)SQLException - when an exception occurs while creating the prepared statementpublic PreparedStatement sql_getFetchAll(Connection connection, String whereClause, Object[] params) throws SQLException
EventSqlSchemawhereClause. The
given parameters provide the parameters used in the where clause, in the order of declaration.sql_getFetchAll in interface EventSqlSchema<T>connection - The connection to create the PreparedStatement forwhereClause - The SQL snippet to use after the WHERE directive. May be null or an empty String
to indicate that no filter is to be appliedparams - The parameters to set in the WHERE clauseEventSqlSchema.createSerializedDomainEventData(java.sql.ResultSet)SQLException - when an exception occurs while creating the prepared statementprotected Object readTimeStamp(ResultSet resultSet, int columnIndex) throws SQLException
resultSet at given columnIndex. The resultSet is
positioned in the row that contains the data. This method must not change the row in the result set.resultSet - The resultSet containing the stored datacolumnIndex - The column containing the timestampSQLException - when an exception occurs reading from the resultSet.protected T readPayload(ResultSet resultSet, int columnIndex) throws SQLException
resultSet at given columnIndex. The resultSet
is positioned in the row that contains the data. This method must not change the row in the result set.resultSet - The resultSet containing the stored datacolumnIndex - The column containing the timestampSQLException - when an exception occurs reading from the resultSet.public PreparedStatement sql_createSnapshotEventEntryTable(Connection connection) throws SQLException
EventSqlSchemasql_createSnapshotEventEntryTable in interface EventSqlSchema<T>connection - The connection to create the PreparedStatement forSQLException - when an exception occurs while creating the prepared statementpublic PreparedStatement sql_createDomainEventEntryTable(Connection connection) throws SQLException
EventSqlSchemasql_createDomainEventEntryTable in interface EventSqlSchema<T>connection - The connection to create the PreparedStatement forSQLException - when an exception occurs while creating the prepared statementpublic SerializedDomainEventData<T> createSerializedDomainEventData(ResultSet resultSet) throws SQLException
EventSqlSchemacreateSerializedDomainEventData in interface EventSqlSchema<T>resultSet - The result set returned from executing one of the Prepared Statements declared on this
interfaceSQLException - when an exception occurs while creating the prepared statementSimpleSerializedDomainEventDatapublic String sql_dateTime(org.joda.time.DateTime input)
EventSqlSchemaDateTime to a data value suitable for the database scheme.sql_dateTime in interface EventSqlSchema<T>input - DateTime to convertpublic Class<T> getDataType()
EventSqlSchemagetDataType in interface EventSqlSchema<T>Copyright © 2010-2014. All Rights Reserved.