Skip to content

How to express a link to self #78

Closed Answered by odrotbohm
MehrCurry asked this question in Q&A
Discussion options

You must be logged in to vote

Sorry for not seeing this earlier: the reason for the effect you see is that Location – by definition – is an Entity. Entities are "owned" by the aggregates they're contained in, i.e. no two aggregates must refer to the same entity as state changes issued by one aggregate might affect the consistency of the other. Thus, a @OneToOne mapping is the only reasonable way to map singular properties that are entities.

That said, the entity referred to is also an AggregateRoot. Following the pure theory, references to an aggregate either should be identifier references or modeled as an Association. That takes the relationship out of the loop for Hibernate's automatic relationship management, as i…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by odrotbohm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants