Base Saga
JPA-backed base implementation of the Saga port.
The Saga port exposes its fields as val (immutable from the engine's point of view). Internally this class uses var because Jakarta Persistence requires writable fields for proxy/dirty-tracking. State transitions are exclusively performed via behavior methods (DDD rich aggregate) which mutate the same instance and return this — Hibernate then issues a partial UPDATE on flush.
Mongo/Cassandra adapters can implement these methods by returning a fresh copy of the document instead. The engine never observes this difference.
Constructors
Properties
Instant the saga reached a terminal status; null while it is still in flight.
Current lifecycle SagaStatus; see the enum for the full state machine.
Saga type discriminator (e.g. "UserRegistration"). Conventionally a SagaTypeValue.
Functions
Transitions to SagaStatus.AWAITING_RESPONSE and stamps updatedAt.
Transitions to SagaStatus.COMPENSATED and stamps completedAt/updatedAt.
Transitions to SagaStatus.COMPENSATION_FAILED and stamps completedAt/updatedAt.
Transitions to SagaStatus.COMPLETED and stamps completedAt/updatedAt.
Transitions to SagaStatus.FAILED, stores error as lastError, and stamps completedAt/updatedAt.
Transitions to SagaStatus.COMPENSATING, stores error as lastError, and stamps updatedAt. Used when a step failure triggers compensation but the saga has not yet completed compensation.