Skip to main content

2015 | OriginalPaper | Buchkapitel

6. Collection Mapping

verfasst von : Joseph Ottinger, Srinivas Guruzu, Gary Mak

Erschienen in: Hibernate Recipes

Verlag: Apress

Aktivieren Sie unsere intelligente Suche, um passende Fachinhalte oder Patente zu finden.

search-config
loading …

Abstract

Collection mapping refers to the concept of an object in the database—an entity—that possesses references to a set of other objects, none of which exists outside the context of the owning object. An example is an order line item: an order has many line items, although it might exist without any. However, because a line item does not have any way to exist outside of the context of its order, the order might be said to have a collection of line items.

Sie haben noch keine Lizenz? Dann Informieren Sie sich jetzt über unsere Produkte:

Springer Professional "Wirtschaft+Technik"

Online-Abonnement

Mit Springer Professional "Wirtschaft+Technik" erhalten Sie Zugriff auf:

  • über 102.000 Bücher
  • über 537 Zeitschriften

aus folgenden Fachgebieten:

  • Automobil + Motoren
  • Bauwesen + Immobilien
  • Business IT + Informatik
  • Elektrotechnik + Elektronik
  • Energie + Nachhaltigkeit
  • Finance + Banking
  • Management + Führung
  • Marketing + Vertrieb
  • Maschinenbau + Werkstoffe
  • Versicherung + Risiko

Jetzt Wissensvorsprung sichern!

Springer Professional "Technik"

Online-Abonnement

Mit Springer Professional "Technik" erhalten Sie Zugriff auf:

  • über 67.000 Bücher
  • über 390 Zeitschriften

aus folgenden Fachgebieten:

  • Automobil + Motoren
  • Bauwesen + Immobilien
  • Business IT + Informatik
  • Elektrotechnik + Elektronik
  • Energie + Nachhaltigkeit
  • Maschinenbau + Werkstoffe




 

Jetzt Wissensvorsprung sichern!

Springer Professional "Wirtschaft"

Online-Abonnement

Mit Springer Professional "Wirtschaft" erhalten Sie Zugriff auf:

  • über 67.000 Bücher
  • über 340 Zeitschriften

aus folgenden Fachgebieten:

  • Bauwesen + Immobilien
  • Business IT + Informatik
  • Finance + Banking
  • Management + Führung
  • Marketing + Vertrieb
  • Versicherung + Risiko




Jetzt Wissensvorsprung sichern!

Fußnoten
1
A Set and a List might look the same to the database—or they might not. A List might need to include the ordering of each referenced object. A Set means each contained object is referenced only once by that particular collection, which might have implications on the database structure as well.
 
2
You will see how this is done in a few pages.
 
3
As in previous chapters, this configuration does not yet include the data from other recipes in this chapter.
 
4
An embeddable item doesn’t have its own primary key and doesn’t need the @ManyToOne relationship included because it doesn’t exist outside of the relationship with its containing object.
 
5
Mapping entities with XML rather than annotations is usually mandated for odd mappings or for mappings that leverage specific container features such as idbags. This is noted with some chagrin by one of your authors, who far prefers annotations if there is any possibility to use them for mapping, but uses XML when forced to do so, as in this case.
 
6
And lions and tigers and bears, oh my! Imagine the joy in the world if only Lombok were to add annotations for @Lions, @Tigers, and @Bears (and @OhMy). I have no idea what these annotations would do, though.
 
7
This should not be a surprise.
 
8
This description of what a set of key/value associations is called is brought to you by the Ghost of Robert Sedgewick, who’d be surprised greatly at its mere existence—because as of this writing, Dr. Sedgewick is still quite alive.
 
9
Under most circumstances, this is exactly what you want; after all, having the ability to map an object to a relational database is why you use Hibernate in the first place.
 
10
Our example would be a tautology: something that is described in context of itself, such as “a pizza is pizza-shaped.” Hopefully, the test for the specific type shows that the instance constructed from the database acts like the instance we persisted, but isn’t the same. It is like a Stepford Object.
 
11
In other words, it should be a Comparator.
 
13
Random reviews match what most people expect reviews to be, aside from grammar.
 
14
Chapters? We don’t need no stinkin’ chapters!
 
Metadaten
Titel
Collection Mapping
verfasst von
Joseph Ottinger
Srinivas Guruzu
Gary Mak
Copyright-Jahr
2015
Verlag
Apress
DOI
https://doi.org/10.1007/978-1-4842-0127-5_6

Premium Partner