</cmp-field>
<primkey-field>name</primkey-field>
</entity>
</enterprise-beans>
<relationships>
<ejb-relation>
<ejb-relation-name>userInfo-user</ejb-relation-name>
<ejb-relationship-role>
<description>userInfo</description>
<ejb-relationship-role-name>UserInfoRelationshipRole</ejb-relationship-role-name>
<multiplicity>One</multiplicity>
<cascade-delete />
<relationship-role-source>
<description>userInfo</description>
<ejb-name>UserInfo</ejb-name>
</relationship-role-source>
<cmr-field>
<description>user</description>
<cmr-field-name>user</cmr-field-name>
</cmr-field>
</ejb-relationship-role>
<ejb-relationship-role>
<description>user</description>
<ejb-relationship-role-name>UserRelationshipRole</ejb-relationship-role-name>
<multiplicity>One</multiplicity>
<relationship-role-source>
<description>user</description>
<ejb-name>User</ejb-name>
</relationship-role-source>
<cmr-field>
<description>userInfo</description>
<cmr-field-name>userInfo</cmr-field-name>
</cmr-field>
</ejb-relationship-role>
</ejb-relation>
</relationships>
<assembly-descriptor>
<container-transaction>
<method>
<ejb-name>User</ejb-name>
<method-name>*</method-name>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
<container-transaction>
<method>
<ejb-name>UserManager</ejb-name>
<method-name>*</method-name>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
<container-transaction>
<method>
<ejb-name>UserInfo</ejb-name>
<method-name>*</method-name>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
</assembly-descriptor>
</ejb-jar>
接下来是访问EJB的客户端,我们用了一个servlet.
ManaServlet.java
package usersystem.servlet;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import usersystem.*;
import javax.naming.*;
import javax.ejb.*;
import javax.ejb.*;
import javax.ejb.*;
/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2002</p>
* <p>Company: </p>
* @author unascribed
* @version 1.0
*/
public class ManaServlet extends HttpServlet {
static final private String CONTENT_TYPE = "text/html; charset=GBK";
private UserManagerLocalHome h=null;
private UserManagerLocal uml=null;
public void init() throws ServletException{