I
- the type of aggregate IDspublic class JdbcAggregateStorage<I>
extends io.spine.server.aggregate.AggregateStorage<I>
This storage contains two tables by default:
AggregateEventRecordTable
LifecycleFlagsTable
Modifier and Type | Class and Description |
---|---|
static class |
JdbcAggregateStorage.Builder<I>
The builder for
JdbcAggregateStorage . |
Modifier | Constructor and Description |
---|---|
protected |
JdbcAggregateStorage(JdbcAggregateStorage.Builder<I> builder)
Creates a new instance using the builder.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the storage.
|
protected java.util.Iterator<io.spine.server.aggregate.AggregateEventRecord> |
historyBackward(io.spine.server.aggregate.AggregateReadRequest<I> request) |
java.util.Iterator<I> |
index() |
static <I> JdbcAggregateStorage.Builder<I> |
newBuilder()
Creates the builder for the storage.
|
java.util.Optional<io.spine.server.entity.LifecycleFlags> |
readLifecycleFlags(I id) |
protected void |
truncate(int snapshotIndex) |
protected void |
truncate(int snapshotIndex,
com.google.protobuf.Timestamp date) |
void |
writeLifecycleFlags(I id,
io.spine.server.entity.LifecycleFlags status) |
protected void |
writeRecord(I id,
io.spine.server.aggregate.AggregateEventRecord record) |
checkNotClosed, read, truncateOlderThan, truncateOlderThan, write
checkNotClosed, isClosed, isMultitenant, isOpen
protected JdbcAggregateStorage(JdbcAggregateStorage.Builder<I> builder)
builder
- the storage builderpublic java.util.Iterator<I> index()
public java.util.Optional<io.spine.server.entity.LifecycleFlags> readLifecycleFlags(I id)
public void writeLifecycleFlags(I id, io.spine.server.entity.LifecycleFlags status)
protected void writeRecord(I id, io.spine.server.aggregate.AggregateEventRecord record) throws DatabaseException
Any exceptions occurred in this operation are propagated as DatabaseException
.
writeRecord
in class io.spine.server.aggregate.AggregateStorage<I>
DatabaseException
- if an error occurs during an interaction with the DBprotected java.util.Iterator<io.spine.server.aggregate.AggregateEventRecord> historyBackward(io.spine.server.aggregate.AggregateReadRequest<I> request) throws DatabaseException
NOTE: it is required to call Iterator.hasNext()
before
Iterator.next()
.
historyBackward
in class io.spine.server.aggregate.AggregateStorage<I>
DbIterator
instanceDatabaseException
- if an error occurs during an interaction with the DBprotected void truncate(int snapshotIndex)
truncate
in class io.spine.server.aggregate.AggregateStorage<I>
protected void truncate(int snapshotIndex, com.google.protobuf.Timestamp date)
truncate
in class io.spine.server.aggregate.AggregateStorage<I>
public void close() throws DatabaseException
Unclosed history iterators produced by this storage will be closed together with the storage.
close
in interface io.spine.server.storage.Storage<I,io.spine.server.aggregate.AggregateHistory,io.spine.server.aggregate.AggregateReadRequest<I>>
close
in interface java.lang.AutoCloseable
close
in class io.spine.server.storage.AbstractStorage<I,io.spine.server.aggregate.AggregateHistory,io.spine.server.aggregate.AggregateReadRequest<I>>
DatabaseException
- if the underlying datasource cannot be closedpublic static <I> JdbcAggregateStorage.Builder<I> newBuilder()