OwnerId

Marks a field or property as containing the owner identifier for multi-tenant scenarios.

The owner ID represents the tenant or user context that owns the data. This annotation is used by the framework to:

  • Enforce ownership-based access control

  • Route commands to correct tenant contexts

  • Isolate data between different owners

  • Generate tenant-specific API endpoints

The annotated field/property should contain a unique identifier for the owner/tenant, such as a user ID, organization ID, or tenant key.

Example usage:

@AggregateRoot
@AggregateRoute(owner = AggregateRoute.Owner.ALWAYS)
class UserProfile(
@AggregateId
val profileId: String,

@OwnerId
val userId: String // The user who owns this profile
)

// Command targeting the user's profile
data class UpdateProfileCommand(
@AggregateId
val profileId: String,

@OwnerId
val userId: String, // Must match the authenticated user

val newName: String
)

See also

for tenant-specific identification

for ownership routing policies