LockOrdering enum

Defines the order in which locks are acquired during commit.

Lock ordering is critical for preventing deadlocks when multiple transactions commit simultaneously. The order must be consistent across all transactions.

When to use

  • byHashCode – default, uses cell hash codes for ordering.
  • insertion – uses the order passed to begin.
  • explicit – uses a custom comparator.
Inheritance
Available extensions

Values

byHashCode → const LockOrdering

Order locks by cell hash code.

This is the default and ensures a deterministic order that is consistent across all transactions. Deadlocks are prevented because all transactions acquire locks in the same order.

insertion → const LockOrdering

Order locks by the insertion order passed to begin.

Locks are acquired in the exact order the cells were provided. This can be useful if you have a natural order in your domain.

explicit → const LockOrdering

Use a custom comparator provided in TransactionOptions.comparator.

This gives you full control over lock ordering. The comparator must be total and consistent with ==.

Properties

hashCode → int
The hash code for this object.
no setterinherited
index → int
A numeric identifier for the enumerated value.
no setterinherited
name → String

Available on Enum, provided by the EnumName extension

The name of the enum value.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Constants

values → const List<LockOrdering>
A constant List of the values in this enum, in order of their declaration.