Annotation Interface Member
Entities marked with @Member
participate in aggregate routing, event sourcing, and update application. When
an update targets a nested entity, Flux will use this annotation to traverse the aggregate structure and locate the
correct entity (or entities) to apply the update to.
This annotation supports modeling complex aggregates composed of multiple entities, for example:
@Aggregate
public class Project {
@EntityId
String projectId;
@Member
List<Task> tasks;
}
Here, updates targeting Task
entities will automatically be routed by matching TaskId
(declared with
EntityId
) inside the Task
class.
Support for new entities
If no matching entity is found for a given update, Flux will still evaluate the update against applicable
@Apply
and @AssertLegal
methods. This allows new entity creation directly from the update payload
when appropriate logic is defined.
For example:
@Apply
Task create() {
return Task.builder().taskId(taskId).details(taskDetails).build();
}
will be used to create a new Task
if no matching task exists in the tasks
member list.
Immutability and parent updates
Flux assumes immutability by default. When a nested entity is added, removed, or modified, Flux will attempt to
create a new version of the parent entity by copying and updating the annotated container field (list, map, etc.).
The parent is not modified directly.
This behavior ensures safe update propagation and accurate change tracking, especially during event sourcing.
For example, if ProductCategory
has a list of Product
s:
@Member
List<Product> products;
and one product is updated, Flux will replace the products
list with a new list containing the updated
entity.
Optional attributes
idProperty
(default: empty):
Use this to explicitly specify the identifier property name on the nested entity. By default, Flux locates the identifier via theEntityId
annotation.wither
(default: empty):
Defines a method (by name) that should be invoked to update the container when the entity is added, removed, or replaced. Normally, Flux will update the container (e.g., list or map) automatically. This setting is useful for immutable containers or cases requiring side effects during updates.
Supported container types:
- Single nested entities (e.g.,
Product product
) - Collections of entities (e.g.,
List<Product>
) - Maps of entities keyed by their identifier
- See Also:
-
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionSpecifies the name of the identifier property on the nested entity, if different from the default detected one.Optionally defines the name of a method that should be used to apply updates to the container of the nested entity.
-
Element Details
-
idProperty
String idPropertySpecifies the name of the identifier property on the nested entity, if different from the default detected one.- Default:
""
-
wither
String witherOptionally defines the name of a method that should be used to apply updates to the container of the nested entity.Normally, Flux automatically updates the container (for lists, maps, or singletons). This attribute is only necessary if a custom update method must be invoked instead.
- Default:
""
-