5
* Copyright � 2007 Sun Microsystems, Inc. All rights reserved.
6
* Use is subject to license terms.
9
<title>Managing Container-Managed Relationships</title>
10
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
11
<link rel="stylesheet" href="nbdocs:/org/netbeans/modules/usersguide/ide.css" type="text/css">
14
<h2>Managing Container-Managed Relationships</h2>
15
<p><small><a href="#seealso">See Also</a></small></p>
16
<p>CMP relationships are managed by the container based on how the relationships are described
17
in the <tt>ejb-jar.xml</tt> general deployment descriptor. </p>
19
<p><b>To modify CMP relationships in <tt>ejb-jar.xml</tt>:</b></p>
21
<li>In the Projects window, expand the Configuration Files node for the EJB
22
module project and double-click <tt>ejb-jar.xml</tt>.</li>
23
<li>In the top of the graphical editor, click CMP Relationships.
24
<p>The visual editor displays a table of the existing container-managed relationships for the EJB module.
26
<li>Double-click the name of the relationship in the table to open the Edit CMP Relationship dialog box.</li>
27
<li>Edit the relationship description properties in the dialog box.</li>
31
<li>When you edit the relationship in <tt>ejb-jar.xml</tt>, you may also need
32
to make corresponding changes in your source code.</li>
35
<p><b>To remove a CMP relationship in <tt>ejb-jar.xml</tt>:</b></p>
37
<li>In the Projects window, expand the Configuration Files node for the EJB
38
module project and double-click <tt>ejb-jar.xml</tt>.</li>
39
<li>In the top of the graphical editor, click CMP Relationships.
40
<p>The visual editor displays a table of the existing container-managed relationships for the EJB module.
42
<li>Select the name of the relationship in the table and click Remove</li>
45
<h3>Creating a CMP Relationship</h3>
46
<p>If you are you are generating CMP entity beans from scratch and need to specify the CMP relationships for
47
your application, you need to edit the deployment descriptor file in the XML editor.
48
You also need to make the corresponding changes in your source code.
49
When working with CMP entity beans, the IDE does not update your source code based on changes you make in <tt>ejb-jar.xml</tt>.</p>
50
<p><b>To create new CMP relationships in <tt>ejb-jar.xml</tt>:</b></p>
52
<li>In the Projects window, expand the Configuration Files node for the EJB
53
module project and double-click <tt>ejb-jar.xml</tt>.</li>
54
<li>Click the XML tab and edit the deployment descriptor file in the XML editor.</li>
57
<p>Each CMP relationship requires the following.</p>
59
<li>A relationship name.</li>
60
<li>Each end of the relationships requires that the following is defined.
62
<li>A distinct name for the relationship role and the entity bean in which
63
the relationship begins or ends.</li>
64
<li>The multiplicity of the relationship. </li>
65
<li>Whether cascade delete is enabled for the either side of the relationship.
66
When you enable cascade delete for a bean in a relationship, deleting
67
the bean also deletes the bean it is related to.</li>
68
<li>Whether to create a Container-Managed Relationship (CMR) field for the
69
bean. If you create a CMR field, the application server can search for
70
and return instances of the bean field references. The name of the
71
class must begin with a lower-case letter.</li>
72
<li>The return type of the CMR field. If the multiplicity of the bean it
73
is returning is one, you do not have to specify a return type. The application
74
server automatically returns the enterprise bean's interface.
75
<p> If the multiplicity is set to many, you can choose whether to return
76
<tt>java.util.Set</tt> or <tt>java.util.Collection</tt>. Choose <tt>java.util.Set</tt>
77
if the returned beans cannot be duplicates. Choose <tt>java.util.Collection</tt>
78
if the returned beans can include duplicates.
87
<li>When you generate CMP entity beans from a database, the IDE automatically
88
registers all of the container-managed relationships based on the relationships
90
<li>Changes in the <tt>ejb-jar.xml</tt> deployment descriptor can result in
91
automatic or necessary changes in the corresponding application server-specific
92
deployment descriptors. For example, when you add a relationship in <tt>ejb-jar.xml</tt>,
93
you have to map it to a real database in the server-specific deployment descriptor.</li>
94
<li>You should exercise caution when editing deployment descriptors in XML and always validate your XML file to avoid errors.</li>
98
<p>For a complete list of configurable properties for
99
all J2EE module types, see "Appendix A
100
Deployment Descriptor Files" in
101
the Sun Java System Application Server Developer's
103
<p><object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer">
104
<param name="content" value="http://docs.sun.com/source/819-0079/dgdesc.html">
105
<param name="text" value="<html><u>http://docs.sun.com/source/819-0079/dgdesc.html</u></html>">
106
<param name="textFontSize" value="medium">
107
<param name="textColor" value="blue">
110
<p>For a detailed description of CMP entity bean specifications, see the Enterprise JavaBeans Specification, v2.1.</p>
111
<p><object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer">
112
<param name="content" value="http://java.sun.com/products/ejb/docs.html">
113
<param name="text" value="<html><u>http://java.sun.com/products/ejb/docs.html</u></html>">
114
<param name="textFontSize" value="medium">
115
<param name="textColor" value="blue">
119
<dt><a name="seealso">See Also</a></dt>
120
<dd><a href="../general/about_deployment_descriptors.html">About Deployment Descriptors</a></dd>
121
<dd><a href="config_ejb_dd.html">Configuring EJB Deployment Descriptors</a></dd>
122
<dd><a href="config_ejb_about.html">About Configuring EJB Modules</a></dd>
123
<dd><a href="../editing/generate_cmp_beans.html">Generating CMP Entity Beans from a Database</a></dd>
126
<small><a href="../../credits.html">Legal Notices</a></small>
127
<table cellpadding="50" border="0">
128
<tr><td> </td></tr>
b'\\ No newline at end of file'