Reputation:
I'd like to have your opinion about code organization. I have two entities: City and Country. I have an unidirectional ManyToOne between them, Many side is of course City.
Now, I need to get all the cities corresponding to a country. I have two choices:
What is the best way to do so ?
Upvotes: 0
Views: 46
Reputation: 1986
It depends on what kind of data and how oftend you need it:
@Erik's response is also a good view on the subject
Upvotes: 0
Reputation: 1057
Depends. If the two entities are in the same Bundle (or in Bundles that require each other's presence), then make it bi-directional, especially if you think this'll be a common thing to search for.
On the other hand, if this is a special case, the entities are in different Bundles, and you don't want to couple them further, then it's better to make a custom method for it.
Upvotes: 2