@Getter public class Order { private final @EmbeddedId OrderId id; @OneToMany(cascade = CascadeType.ALL) private List<LineItem> lineItems; private CustomerId customerId; public Order(Customer customer) { this.id = OrderId.of(UUID.randomUUID()); this.customerId = customer.getId(); } @Value @RequiredArgsConstructor(staticName = "of") @NoArgsConstructor(force = true) public static class OrderId implements Serializable { private static final long serialVersionUID = …; private final UUID orderId; } } @Table(name = "SAMPLE_ORDER") @Getter public class Order implements AggregateRoot<Order, OrderId> { private final OrderId id; private List<LineItem> lineItems; private Association<Customer, CustomerId> customer; public Order(Customer customer) { this.id = OrderId.of(UUID.randomUUID()); this.customer = Association.forAggregate(customer); } @Value(staticConstructor = "of") public static class OrderId implements Identifier { private final UUID orderId; } }