Weitere Kapitel dieses Buchs durch Wischen aufrufen
A many-valued association is by definition a collection of references to entities. The collection can be of type List, Set, Map, and so on in Java.
Bitte loggen Sie sich ein, um Zugang zu diesem Inhalt zu erhalten
Sie möchten Zugang zu diesem Inhalt erhalten? Dann informieren Sie sich jetzt über unsere Produkte:
Chapters 5 and 6, among others; we’ve seen a few snippets that use relationships in most of our recipes. If we haven’t, well, we need to read more closely. Which book do you think you’re reading? I know which one I think I’m writing…
We’re revisiting the entity model from Recipe 6.1.
Surprise, right? But there’s a twist: the mapping for Chapter1 in Recipe 7.1 doesn’t have book_id as an attribute, which is why the join column is being described specifically.
As shown at the end of Recipe 1, you generally have to walk the relationship from the owning entity. It can be done in that (and other) ways, but it’s not really convenient or efficient.
If we were willing to play some tricks with reflection, we could have used the same test for all three recipes, passing around Callable objects to change behavior in small ways. However, that would make the example code much harder to read, harder to rely upon, and much more a sample of some author’s coding prowess rather than a useful example of how to test some behavior.
How many books share actual chapters?
We could have added the book title as a “natural id,” built the query as we needed it, or even used a criteria query… and there are more options I’m not thinking of offhand.
- Many-Valued Associations
- Chapter 7
Neuer Inhalt/© ITandMEDIA