@Documented @Retention(value=RUNTIME) @Target(value={METHOD,ANNOTATION_TYPE}) public @interface AggregateId
FluentAssembler DSL needs to get an aggregate from repository (i.e. when the fromRepository() method is used), this annotation allows to specify a matching between a DTO
getter and the identifier of the aggregate.
public class OrderDto {
@AggregateId
public String getId() {...}
}
public class Order extends BaseAggregateRoot<String> {
}
public class CustomerDto {
@AggregateId(index = 0)
public String getFirstName() {...}
@AggregateId(index = 1)
public String getLastName() {...}
// No annotation here as the birth date is not part of the customer id
public Date getBirthDate() {...}
}
public class CustomerId extends BaseValueObject {
public CustomerId(String firstName, String lastName) {...}
}
public class Customer extends BaseAggregateRoot<CustomerId> {
}
public class RecipeDto {
@MatchingEntityId(aggregateIndex = 0, index = 0)
public String getCustomerFirstName() {...}
@MatchingEntityId(aggregateIndex = 0, index = 1)
public String getCustomerLastName() {...}
@MatchingEntityId(aggregateIndex = 1)
public int getOrderId() {...}
}
public class CustomerId extends BaseValueObject {
public CustomerId(String firstName, String lastName) {...}
}
public class Customer extends BaseAggregateRoot<CustomerId> {
}
public class Order extends BaseAggregateRoot<Integer> {
}
| Modifier and Type | Optional Element and Description |
|---|---|
int |
aggregateIndex
When using a tuple assembler, i.e.
|
int |
index
If the aggregate root id is composite, i.e it is a value object, this method indicates
constructor parameter of the value object associated to the annotated method.
|
Copyright © 2013-2018–2019 SeedStack. All rights reserved.