Chapter 8 Creating J2EE Applications for BEA WebLogic
Entity beans can have relationships with other beans. These relationships can be either bidirectional or unidirectional.
You specify relationships in the ejb-jar.xml file and weblogic-cmp-rdbms-jar.xml. You specify container-managed field mappings in the weblogic-cmp-rdbms-jar.xml.
WebLogic Server supports three types of relationship mappings that are managed by WebLogic container-managed persistence (CMP):
A WebLogic Server one-to-one relationship involves the physical mapping from a foreign key in one bean to the primary key in another bean. See Primary Keys for more information on primary keys.
A WebLogic Server one-to-many relationship involves the physical mapping from a foreign key in one bean to the primary key of another. However, in a one-to-many relationship, the foreign key is always contained in the role that occupies the "many" side of the relationship.
A WebLogic Server many-to-many relationship involves the physical mapping of a join table. Each row in the join table contains two foreign keys that map to the primary keys of the entities involved in the relationship.
Unidirectional relationships can only navigate in one direction. These types of relationships are used with remote beans, and only unidirectional relationships can be remote. A remote bean is one whose abstract persistence schema is not defined in the same ejb-jar file. For example, if entity A and entity B are in a one-to-one unidirectional relationship, and the direction is from entity A to entity B, then entity A is aware of entity B but entity B is unaware of entity A. This type of relationship is implemented with a cmr-field on the entity bean from which navigation can take place and no related cmr-field on the target entity bean.
Bidirectional relationships can be navigated in both directions. These types of container-managed relationships can exist only among beans whose abstract persistence schemas are defined in the same ejb-jar file and therefore managed by the same container. For example, if entity A and entity B are in a one-to-one bidirectional relationship, both are aware of each other.
Copyright (C) 2005. Sybase Inc. All rights reserved. |
![]() |