Share on Google+Share on Google+

Match the name with a description of purpose or functionality, for each of the following deployment descriptor elements: ejb-name, abstract-schema-name, ejb-relation, ejb-relat

Advertisement
This page discusses - Match the name with a description of purpose or functionality, for each of the following deployment descriptor elements: ejb-name, abstract-schema-name, ejb-relation, ejb-relat

Match the name with a description of purpose or functionality, for each of the following deployment descriptor elements: ejb-name, abstract-schema-name, ejb-relation, ejb-relationship-role, cmr-field, cmr-field-type, and relationship-role-source.

The deployment descriptor provides the following information about the abstract persistence schemas of entity beans and their container-managed relationships:

  • An ejb-name element for each entity bean. The ejb-name MUST be a valid Java identifier and MUST be UNIQUE within the ejb-jar file.

  • An abstract-schema-name element for each entity bean. The abstract-schema-name MUST be a valid Java identifier and MUST be unique within the ejb-jar file. The abstract-schema-name element is used in the specification of EJB QL queries.

  • A set of ejb-relation elements, each of which contains a PAIR of ejb-relationship-role elements to describe the two roles in the relationship.

  • Each ejb-relationship-role element describes a relationship role: its name, its multiplicity within a relation, and its navigability. It specifies the name of the cmr-field that is used from the perspective of the relationship participant. The cmr-field-type element MUST be specified if the type of the cmr-field is java.util.Collection or java.util.Set. Each relationship role refers to an entity bean by means of an ejb-name element contained in the relationship-role-source element.

					
<ejb-jar>
...
<enterprise-beans>
...
</enterprise-beans>

<relationships>
	<!--
	ONE-TO-MANY: Order LineItem
	-->
	<ejb-relation>
		<ejb-relation-name>Order-LineItem</ejb-relation-name>
		<ejb-relationship-role>
			<ejb-relationship-role-name>
				order-has-lineitems
			</ejb-relationship-role-name>
			<multiplicity>One</multiplicity>
			<relationship-role-source>
				<ejb-name>OrderEJB</ejb-name>
			</relationship-role-source>
			<cmr-field>
				<cmr-field-name>lineItems</cmr-field-name>
				<cmr-field-type>java.util.Collection</cmr-field-type>
			</cmr-field>
		</ejb-relationship-role>
		<ejb-relationship-role>
			<ejb-relationship-role-name>
				lineitem-belongsto-order
			</ejb-relationship-role-name>
			<multiplicity>Many</multiplicity>
			<cascade-delete/>
			<relationship-role-source>
				<ejb-name>LineItemEJB</ejb-name>
			</relationship-role-source>
			<cmr-field>
				<cmr-field-name>order</cmr-field-name>
			</cmr-field>
		</ejb-relationship-role>
	</ejb-relation>
	
	<!--
	ONE-TO-MANY unidirectional relationship:
	Product is not aware of its relationship with LineItem
	-->
	<ejb-relation>
		<ejb-relation-name>Product-LineItem</ejb-relation-name>
		<ejb-relationship-role>
			<ejb-relationship-role-name>					
				product-has-lineitems
			</ejb-relationship-role-name>
			<multiplicity>One</multiplicity>
			<relationship-role-source>
				<ejb-name>ProductEJB</ejb-name>
			</relationship-role-source>
			<!-- since Product does not know about LineItem
			there is no cmr field in Product for accessing
			Lineitem
			-->
		</ejb-relationship-role>
		<ejb-relationship-role>
			<ejb-relationship-role-name>
				lineitem-for-product
			</ejb-relationship-role-name>
			<multiplicity>Many</multiplicity>
			<relationship-role-source>
				<ejb-name>LineItemEJB</ejb-name>
			</relationship-role-source>
			<cmr-field>
				<cmr-field-name>product</cmr-field-name>
			</cmr-field>
		</ejb-relationship-role>
	</ejb-relation>

	<!--
	ONE-TO-MANY: Order Customer:
	-->
	<ejb-relation>
		<ejb-relation-name>Order-Customer</ejb-relation-name>
		<ejb-relationship-role>
			<ejb-relationship-role-name>
				customer-has-orders
			</ejb-relationship-role-name>
			<multiplicity>One</multiplicity>
			<relationship-role-source>
				<ejb-name>CustomerEJB</ejb-name>
			</relationship-role-source>
			<cmr-field>
				<cmr-field-name>orders</cmr-field-name>
				<cmr-field-type>
					java.util.Collection
				</cmr-field-type>
			</cmr-field>
		</ejb-relationship-role>
		<ejb-relationship-role>
			<ejb-relationship-role-name>
				order-belongsto-customer
			</ejb-relationship-role-name>
			<multiplicity>Many</multiplicity>
			<relationship-role-source>
				<ejb-name>OrderEJB</ejb-name>
			</relationship-role-source>
			<cmr-field>
				<cmr-field-name>customer</cmr-field-name>
			</cmr-field>
		</ejb-relationship-role>
	</ejb-relation>
</relationships>
...
</ejb-jar>
					
					

Advertisements

Posted on: April 18, 2011 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Comments:0