I have a registration form for users that can insert multiple addresses. I take User as an entity but I am not sure about collections of addresses. if it was only one address I would take it as ValueObject but I am not sure what about collections of addresses. if I have to take them as ValueObject how can I store them in tables, do I need to define a new table for it, if Yes they get Ids that are wrong for ValueObject.
Asked
Active
Viewed 151 times
1 Answers
0
Collection of addresses is fine as a value object.
The fact that your storage implementation requires multiple rows (with identifiers?) is an implementation detail of storage that has nothing to do with the model of your domain.

VoiceOfUnreason
- 52,766
- 5
- 49
- 91
-
Are the identifiers then part of the domain or is there a translation from the value object to the identifier? I understand that persistence is not part of the model, but somewhere needs there be a relation between the identifier and the value object. – Pakspul Aug 29 '21 at 18:16
-
The row of your value probably includes an identifier for the entity: select * from items where orderId = ? – VoiceOfUnreason Aug 30 '21 at 03:09