xmolecules/jmolecules

Bound of `T` for `ddd.types.Entity<T, ID>` is wrong?

larsw opened this issue · 1 comments

larsw commented

The current interface states

public interface Entity<T extends AggregateRoot<T, ?>, ID> extends Identifiable<ID> {}

Is this a cut'n'paste error? Shouldn't the bound of T be Entity<T, ID?

No. As described here (the section starting with "There's still one question that we haven't answered yet…"), an entity defines which aggregate it belongs to, as it can only be owned by one aggregate. This allows to detect that an entity is referred to from an aggregate it doesn't belong (the OrderItem in the Customer type in the example).