Migration

public abstract class Migration<I, E extends TransactionalEntity<I, S, ? extends Object>, S extends EntityState> implements Function<T, R>

A stored Entity transformation done to account for the domain model changes.

At its core the Migration is a mapping of entity state, from old to new. It is also capable of performing basic entity modifications like archiving and deleting it.

The process of applying the migration operation is always preceded by an Entity load by ID and may be finalized by either saving the transformed entity back to the repository or by deleting the entity record if the migration is configured to do so.

All entity modifications are applied under the opened entity Transaction. The last step of a migration operation is a transaction commit. As a consequence, all entity lifecycle events occur as expected, having the MigrationApplied event as the producing message.

To create a user-defined Migration in real life scenarios, consider inheriting from ProjectionMigration and ProcessManagerMigration types.

Parameters

<I>

the entity ID type

<E>

the entity type

<S>

the entity state type

Inheritors

Constructors

Link copied to clipboard
public void Migration()

Functions

Link copied to clipboard
protected final I id()
Returns the ID of an entity under migration.
Link copied to clipboard
protected final boolean isArchived()
Returns true if the entity under migration is archived.
Link copied to clipboard
protected final boolean isDeleted()
Returns true if the entity under migration is deleted.
Link copied to clipboard
protected final void markArchived()
Marks the entity under migration as archived.
Link copied to clipboard
protected final void markDeleted()
Marks the entity under migration as deleted.
Link copied to clipboard
protected final void removeFromStorage()
Configures the migration operation to delete the entity record from the storage.
Link copied to clipboard
protected abstract Transaction<I, E, S, ? extends Object> startTransaction(E entity)
Opens a transaction on an entity.
Link copied to clipboard
protected final Version version()
Returns the version of entity under migration.

Inherited functions

Link copied to clipboard
public Function<T, V> andThen<V>(Function<? extends Object, ? extends V> after)
Link copied to clipboard
public abstract R apply(T p)
Link copied to clipboard
public Function<V, R> compose<V>(Function<? extends Object, ? extends T> before)
Link copied to clipboard
public static Function<T, T> identity<T>()