() -> format("Token [%s] is of the wrong type", lastToken)); GapAwareTrackingToken previousToken = (GapAwareTrackingToken) lastToken; String sql = "SELECT " + trackedEventFields() + " FROM " + schema.domainEventTable() + " WHERE (" + schema.globalIndexColumn() + " > ? AND " + schema.globalIndexColumn() + " <= ?) "; List<Long> gaps;
/** * Creates a statement to read domain event entries for an aggregate with given identifier starting with the first * entry having a sequence number that is equal or larger than the given {@code firstSequenceNumber}. * * @param connection The connection to the database. * @param identifier The identifier of the aggregate. * @param firstSequenceNumber The expected sequence number of the first returned entry. * @param batchSize The number of items to include in the batch * @return A {@link PreparedStatement} that returns event entries for the given query when executed. * * @throws SQLException when an exception occurs while creating the prepared statement. */ protected PreparedStatement readEventData(Connection connection, String identifier, long firstSequenceNumber, int batchSize) throws SQLException { Transaction tx = transactionManager.startTransaction(); try { final String sql = "SELECT " + trackedEventFields() + " FROM " + schema.domainEventTable() + " WHERE " + schema.aggregateIdentifierColumn() + " = ? AND " + schema.sequenceNumberColumn() + " >= ? AND " + schema.sequenceNumberColumn() + " < ? ORDER BY " + schema.sequenceNumberColumn() + " ASC"; PreparedStatement preparedStatement = connection.prepareStatement(sql); preparedStatement.setString(1, identifier); preparedStatement.setLong(2, firstSequenceNumber); preparedStatement.setLong(3, firstSequenceNumber + batchSize); return preparedStatement; } finally { tx.commit(); } }
() -> format("Token [%s] is of the wrong type", lastToken)); GapAwareTrackingToken previousToken = (GapAwareTrackingToken) lastToken; String sql = "SELECT " + trackedEventFields() + " FROM " + schema.domainEventTable() + " WHERE (" + schema.globalIndexColumn() + " > ? AND " + schema.globalIndexColumn() + " <= ?) "; List<Long> gaps;
() -> format("Token [%s] is of the wrong type", lastToken)); GapAwareTrackingToken previousToken = (GapAwareTrackingToken) lastToken; String sql = "SELECT " + trackedEventFields() + " FROM " + schema.domainEventTable() + " WHERE (" + schema.globalIndexColumn() + " > ? AND " + schema.globalIndexColumn() + " <= ?) "; List<Long> gaps;
/** * Creates a statement to read domain event entries for an aggregate with given identifier starting with the first * entry having a sequence number that is equal or larger than the given {@code firstSequenceNumber}. * * @param connection The connection to the database. * @param identifier The identifier of the aggregate. * @param firstSequenceNumber The expected sequence number of the first returned entry. * @param batchSize The number of items to include in the batch * @return A {@link PreparedStatement} that returns event entries for the given query when executed. * @throws SQLException when an exception occurs while creating the prepared statement. */ protected PreparedStatement readEventData(Connection connection, String identifier, long firstSequenceNumber, int batchSize) throws SQLException { Transaction tx = transactionManager.startTransaction(); try { final String sql = "SELECT " + trackedEventFields() + " FROM " + schema.domainEventTable() + " WHERE " + schema.aggregateIdentifierColumn() + " = ? AND " + schema.sequenceNumberColumn() + " >= ? AND " + schema.sequenceNumberColumn() + " < ? ORDER BY " + schema.sequenceNumberColumn() + " ASC"; PreparedStatement preparedStatement = connection.prepareStatement(sql); preparedStatement.setString(1, identifier); preparedStatement.setLong(2, firstSequenceNumber); preparedStatement.setLong(3, firstSequenceNumber + batchSize); return preparedStatement; } finally { tx.commit(); } }
/** * Creates a statement to read domain event entries for an aggregate with given identifier starting with the first * entry having a sequence number that is equal or larger than the given {@code firstSequenceNumber}. * * @param connection The connection to the database. * @param identifier The identifier of the aggregate. * @param firstSequenceNumber The expected sequence number of the first returned entry. * @param batchSize The number of items to include in the batch * @return A {@link PreparedStatement} that returns event entries for the given query when executed. * * @throws SQLException when an exception occurs while creating the prepared statement. */ protected PreparedStatement readEventData(Connection connection, String identifier, long firstSequenceNumber, int batchSize) throws SQLException { Transaction tx = transactionManager.startTransaction(); try { final String sql = "SELECT " + trackedEventFields() + " FROM " + schema.domainEventTable() + " WHERE " + schema.aggregateIdentifierColumn() + " = ? AND " + schema.sequenceNumberColumn() + " >= ? AND " + schema.sequenceNumberColumn() + " < ? ORDER BY " + schema.sequenceNumberColumn() + " ASC"; PreparedStatement preparedStatement = connection.prepareStatement(sql); preparedStatement.setString(1, identifier); preparedStatement.setLong(2, firstSequenceNumber); preparedStatement.setLong(3, firstSequenceNumber + batchSize); return preparedStatement; } finally { tx.commit(); } }