Any-Based Relationships
A relationship based on the concept of an any endpoint (for example, one-to-any or any-to-any) allows you to map a relationship from one table to more than one other table.
For example, let's say that you have three tables, a House table, an Auto table, and a transaction table. The application wishes to record transactions in which a person has bought or sold either a car or a house. Figure 7.3 shows this relationship as expressed in the database.

As shown in Figure 7.3, by using an any relationship, you store a reference in each transaction with an reference identifier and a discriminator indicating the proper target table.
For more information and some examples of different types of relationships, see http://www.xylax.net/hibernate/, which provides a list of mapping types, with explanations in terms of both the database schema and the Java code.
|