Abstract
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.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Notes
- 1.
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…
- 2.
We’re revisiting the entity model from Recipe 6.1.
- 3.
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.
- 4.
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.
- 5.
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.
- 6.
How many books share actual chapters?
- 7.
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.
Author information
Authors and Affiliations
Rights and permissions
Copyright information
© 2015 Joseph Ottinger
About this chapter
Cite this chapter
Ottinger, J., Guruzu, S., Mak, G. (2015). Many-Valued Associations. In: Hibernate Recipes. Apress, Berkeley, CA. https://doi.org/10.1007/978-1-4842-0127-5_7
Download citation
DOI: https://doi.org/10.1007/978-1-4842-0127-5_7
Published:
Publisher Name: Apress, Berkeley, CA
Print ISBN: 978-1-4842-0128-2
Online ISBN: 978-1-4842-0127-5
eBook Packages: Professional and Applied ComputingApress Access BooksProfessional and Applied Computing (R0)