From the DDD book by Eric Evans:
VALUE OBJECTS can even reference ENTITIES. For example, if I ask an online map service for a scenic driving route from San Francisco to Los Angeles, it might derive a Route object linking L.A. and San Francisco via the Pacific Coast Highway. That Route object would be a VALUE, even though the three objects it references (two cities and a highway) are all ENTITIES.
In Hibernate if I have a value object I can map it with as a component. What if I want to reference an entity form that component?
Example:
- I have a Users table.
- Each User can have many addresses.
- I create a addresses table, but I treat the addresses as value objects in my domain.
- Each address have a type (work address, home address,...etc.)
- I create a address type table as a look up and treat it as an entity in my domain.
- An address should have a reference to it type.
How can I achieve that?