Weitere Kapitel dieses Buchs durch Wischen aufrufen
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.
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:
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.
You will see how this is done in a few pages.
As in previous chapters, this configuration does not yet include the data from other recipes in this chapter.
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.
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.
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.
This should not be a surprise.
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.
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.
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.
In other words, it should be a Comparator.
Random reviews match what most people expect reviews to be, aside from grammar.
Chapters? We don’t need no stinkin’ chapters!
- Collection Mapping
- Chapter 6
Neuer Inhalt/© ITandMEDIA