Chained Transaction

Problem

How can a client application organize a set of domain model changes to be submitted in a series of transactions while holding locks across transaction boundaries?

Context

You are developing a client application that commits a series of transactions on an application server for a single business transaction. An object is to be updated in more than one of these transactions.

Forces

Solution

Commit the work of a Flat Transaction and then remain in a transaction, while holding previous locks.

Resulting Context

Each transaction in the chain is treated as a Flat Transaction. However, this solution has the added complexity that you need to specify the scope for obtaining and releasing a write lock.

Rationale

This model provides a way increase the probability of being able to commit a series of changes to an object, even if those changes are performed in separate transactions.

Related Patterns

For other solutions to this same problem, see the list of patterns for selecting a transaction model.