June 2017
Intermediate to advanced
394 pages
8h 52m
English
In case you want to persist and query an Entity by its related Value Objects, you have the choice to persist the Value Objects as Entities. In terms of the Domain, those objects would still be Value Objects, but we'll need to give them an id and set them up with a one-to-many/one-to-one relation with the owner, a real Entity. To summarize, your ORM handles the collection of Value Objects as Entities, but in your Domain, they're still treated as Value Objects.
The main idea behind the Join Table strategy is to create a table that connects the owner Entity and its Value Objects. Let's see a database representation:
CREATE TABLE ` historical_products` ( `id` char( 36) COLLATE utf8mb4_unicode_ci NOT NULL, `name` ...