@ejbgen:relation Annotation

This tag specifies an entity relationship between two CMP entity beans.

Scope

Class tag on an entity bean.

Syntax

@ejbgen:relation

[db-cascade-delete="True/False"]

[cascade-delete="True/False"]

[cmr-field="CMRFieldName"]

[fk-column="ForeignKeyColumnName"]

[foreign-key-table="ForeignKeyTableName"]

[id="TagID"]

[joint-table="JointTableName"]

multiplicity="One/Many"

name="RelationshipName"

[primary-key-table="PKTableName"]

[role-name="RoleName"]

[target-ejb="TagetEJBName"]

Attributes

db-cascade-delete

Optional. Specifies whether a cascade delete will use the built-in cascade delete facilities of the underlying DBMS. Valid values are true and false. When left unspecified, the default is false. All of the major databases have a built-in cascade delete function. Please verify that the underlying database supports cascade delete before enabling this feature.

cascade-delete

Optional. Specifies whether deletion of the entity bean should trigger a cascade delete for this entity relation. Valid values are true and false. When left unspecified, the default is false.

cmr-field

Optional. Specifies the CMR field where this relationship will be stored. This attribute is only specified for certain relationships. For more details, see Entity Relationships.

fk-column

Optional. Specifies the column(s) in the database table for the entity bean that holds the primary key(s) values of the other EJB engaged in the entity relation. This attribute is only specified for certain relationships. For more details, see Entity Relationships.

foreign-key-table

Optional. Specifies the name of the database table that contains the foreign key. This attribute only needs to be specified when this entity bean is mapped to multiple tables.

id

Optional. Specifies the ID of the tag. For more information, see EJBGen Tag Inheritance.

joint-table

Optional. Specifies the name of the joint table that is used to hold the primary keys values of the two entity beans involved in this entity relation. This attribute is only specified for Many-to-Many relationships. For more details, see Entity Relationships.

multiplicity

Required. Specifies the multiplicity of the relationship. Valid values are One and Many.

name

Required. Specifies the name of the relationship. The name is used to identify the relationship, so the same must be used by both entity beans in this relationship.

primary-key-table

Optional. Specifies the name of the database table that contains the primary key. This attribute only needs to be specified when this entity bean is mapped to multiple tables.

role-name

Optional. Specifies the name of this role.

target-ejb

Optional. Specifies the name of the other EJB name in this relationship.

Remarks

When you use the Add Relation Wizard to specify an entity relation, the correct ejbgen:relation tags and attributes are added to both EJBs in the entity relation, reducing development time and the likelihood of errors.

Related Topics

Entity Relationships

How Do I: Add a Relation to an Entity Bean?