Skip to main content

Many-Valued Associations

  • Chapter
  • First Online:
Hibernate Recipes

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.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 29.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 16.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Notes

  1. 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. 2.

    We’re revisiting the entity model from Recipe 6.1.

  3. 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. 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. 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. 6.

    How many books share actual chapters?

  7. 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

Authors

Rights and permissions

Reprints 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

Publish with us

Policies and ethics