Skip Headers
Oracle® TopLink Developer's Guide
10g (10.1.3.1.0)
B28218-01
  Go To Documentation Library
Library
Go To Product List
Product
Go To Table Of Contents
Contents
Go To Index
Index

Previous
Previous
 
Next
Next
 

One-to-Many Mapping

One-to-many mappings are used to represent the relationship between a single source object and a collection of target objects. They are a good example of something that is simple to implement in Java using a Vector (or other collection types) of target objects, but difficult to implement using relational databases.

In a Java Vector, the owner references its parts. In a relational database, the parts reference their owner. Relational databases use this implementation to make querying more efficient.


Note:

See "Configuring Container Policy" for information on using collection classes other than Vector with one-to-many mappings.

The purpose of creating this one-to-one mapping in the target is so that the foreign key information can be written when the target object is saved. Alternatives to the one-to-one mapping back reference include the following:

Figure 33-4 One-to-Many Relationships

Description of Figure 33-4 follows
Description of "Figure 33-4 One-to-Many Relationships "

You can use a many-to-many mapping with a change policy (see "Configuring Change Policy".

See "Configuring a Relational One-to-Many Mapping" for more information.

One-to-Many Mappings and EJB

Use one-to-many mappings for relationships between entity beans or between an entity bean and a collection of privately owned regular Java objects. When you create one-to-many mappings, also create a one-to-one mapping from the target objects back to the source. The object attribute that contains a pointer to the bean must be the local interface type–not the bean class.

TopLink automatically maintains back-pointers when you create or update bidirectional relationships between beans.

For more information, see "Configuring Bidirectional Relationship".