HEr er de:
ejb-jar.xml
<?xml version = '1.0' encoding = 'windows-1252'?>
<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "
http://java.sun.com/dtd/ejb-jar_2_0.dtd"><ejb-jar>
<enterprise-beans>
<session>
<description>Session Bean ( Stateless )</description>
<display-name>MySessionEJB</display-name>
<ejb-name>MySessionEJB</ejb-name>
<home>mypackage6.MySessionEJBHome</home>
<remote>mypackage6.MySessionEJB</remote>
<ejb-class>mypackage6.impl.MySessionEJBBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
<entity>
<description>Entity Bean ( CMP )</description>
<display-name>Status_ids</display-name>
<ejb-name>Status_ids</ejb-name>
<local-home>mypackage6.Status_idsLocalHome</local-home>
<local>mypackage6.Status_idsLocal</local>
<ejb-class>mypackage6.impl.Status_idsBean</ejb-class>
<persistence-type>Container</persistence-type>
<prim-key-class>java.lang.String</prim-key-class>
<reentrant>False</reentrant>
<cmp-version>2.x</cmp-version>
<abstract-schema-name>Status_ids</abstract-schema-name>
<cmp-field>
<field-name>status_id</field-name>
</cmp-field>
<cmp-field>
<field-name>descrip</field-name>
</cmp-field>
<primkey-field>status_id</primkey-field>
<query>
<query-method>
<method-name>findAll</method-name>
<method-params/>
</query-method>
<ejb-ql>SELECT OBJECT(o) FROM Status_ids AS o</ejb-ql>
</query>
</entity>
<entity>
<description>Entity Bean ( CMP )</description>
<display-name>Departments</display-name>
<ejb-name>Departments</ejb-name>
<local-home>mypackage6.DepartmentsLocalHome</local-home>
<local>mypackage6.DepartmentsLocal</local>
<ejb-class>mypackage6.impl.DepartmentsBean</ejb-class>
<persistence-type>Container</persistence-type>
<prim-key-class>java.lang.String</prim-key-class>
<reentrant>False</reentrant>
<cmp-version>2.x</cmp-version>
<abstract-schema-name>Departments</abstract-schema-name>
<cmp-field>
<field-name>department_key</field-name>
</cmp-field>
<cmp-field>
<field-name>department_name</field-name>
</cmp-field>
<cmp-field>
<field-name>company_name</field-name>
</cmp-field>
<primkey-field>department_key</primkey-field>
<query>
<query-method>
<method-name>findAll</method-name>
<method-params/>
</query-method>
<ejb-ql>SELECT OBJECT(o) FROM Departments AS o</ejb-ql>
</query>
</entity>
<entity>
<description>Entity Bean ( CMP )</description>
<display-name>Contacts</display-name>
<ejb-name>Contacts</ejb-name>
<local-home>mypackage6.ContactsLocalHome</local-home>
<local>mypackage6.ContactsLocal</local>
<ejb-class>mypackage6.impl.ContactsBean</ejb-class>
<persistence-type>Container</persistence-type>
<prim-key-class>java.lang.String</prim-key-class>
<reentrant>False</reentrant>
<cmp-version>2.x</cmp-version>
<abstract-schema-name>Contacts</abstract-schema-name>
<cmp-field>
<field-name>contact_key</field-name>
</cmp-field>
<cmp-field>
<field-name>first_nm</field-name>
</cmp-field>
<cmp-field>
<field-name>last_nm</field-name>
</cmp-field>
<cmp-field>
<field-name>address</field-name>
</cmp-field>
<cmp-field>
<field-name>zip_code</field-name>
</cmp-field>
<cmp-field>
<field-name>country</field-name>
</cmp-field>
<cmp-field>
<field-name>phone1</field-name>
</cmp-field>
<cmp-field>
<field-name>phone2</field-name>
</cmp-field>
<cmp-field>
<field-name>email</field-name>
</cmp-field>
<cmp-field>
<field-name>age</field-name>
</cmp-field>
<primkey-field>contact_key</primkey-field>
<query>
<query-method>
<method-name>findAll</method-name>
<method-params/>
</query-method>
<ejb-ql>SELECT OBJECT(o) FROM Contacts AS o</ejb-ql>
</query>
</entity>
<entity>
<description>Entity Bean ( CMP )</description>
<display-name>Groups</display-name>
<ejb-name>Groups</ejb-name>
<local-home>mypackage6.GroupsLocalHome</local-home>
<local>mypackage6.GroupsLocal</local>
<ejb-class>mypackage6.impl.GroupsBean</ejb-class>
<persistence-type>Container</persistence-type>
<prim-key-class>java.lang.String</prim-key-class>
<reentrant>False</reentrant>
<cmp-version>2.x</cmp-version>
<abstract-schema-name>Groups</abstract-schema-name>
<cmp-field>
<field-name>group_key</field-name>
</cmp-field>
<cmp-field>
<field-name>group_name</field-name>
</cmp-field>
<cmp-field>
<field-name>date_add</field-name>
</cmp-field>
<cmp-field>
<field-name>date_avail</field-name>
</cmp-field>
<cmp-field>
<field-name>date_expire</field-name>
</cmp-field>
<cmp-field>
<field-name>status_id</field-name>
</cmp-field>
<cmp-field>
<field-name>descrip</field-name>
</cmp-field>
<primkey-field>group_key</primkey-field>
<query>
<query-method>
<method-name>findAll</method-name>
<method-params/>
</query-method>
<ejb-ql>SELECT OBJECT(o) FROM Groups AS o</ejb-ql>
</query>
</entity>
<entity>
<description>Entity Bean ( CMP )</description>
<display-name>Groups_join</display-name>
<ejb-name>Groups_join</ejb-name>
<local-home>mypackage6.Groups_joinLocalHome</local-home>
<local>mypackage6.Groups_joinLocal</local>
<ejb-class>mypackage6.impl.Groups_joinBean</ejb-class>
<persistence-type>Container</persistence-type>
<prim-key-class>mypackage6.Groups_joinPK</prim-key-class>
<reentrant>False</reentrant>
<cmp-version>2.x</cmp-version>
<abstract-schema-name>Groups_join</abstract-schema-name>
</entity>
<entity>
<description>Entity Bean ( CMP )</description>
<display-name>Users</display-name>
<ejb-name>Users</ejb-name>
<local-home>mypackage6.UsersLocalHome</local-home>
<local>mypackage6.UsersLocal</local>
<ejb-class>mypackage6.impl.UsersBean</ejb-class>
<persistence-type>Container</persistence-type>
<prim-key-class>java.lang.String</prim-key-class>
<reentrant>False</reentrant>
<cmp-version>2.x</cmp-version>
<abstract-schema-name>Users</abstract-schema-name>
<cmp-field>
<field-name>user_key</field-name>
</cmp-field>
<cmp-field>
<field-name>username</field-name>
</cmp-field>
<cmp-field>
<field-name>password</field-name>
</cmp-field>
<cmp-field>
<field-name>status_id</field-name>
</cmp-field>
<cmp-field>
<field-name>date_add</field-name>
</cmp-field>
<cmp-field>
<field-name>date_avail</field-name>
</cmp-field>
<cmp-field>
<field-name>date_expire</field-name>
</cmp-field>
<primkey-field>user_key</primkey-field>
<query>
<query-method>
<method-name>findAll</method-name>
<method-params/>
</query-method>
<ejb-ql>SELECT OBJECT(o) FROM Users AS o</ejb-ql>
</query>
</entity>
<session>
<description>Session Bean ( Stateless )</description>
<display-name>UserFacade</display-name>
<ejb-name>UserFacade</ejb-name>
<home>mypackage6.UserFacadeHome</home>
<remote>mypackage6.UserFacade</remote>
<ejb-class>mypackage6.impl.UserFacadeBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
</enterprise-beans>
<relationships>
<ejb-relation>
<ejb-relation-name>Contacts - Departments</ejb-relation-name>
<ejb-relationship-role>
<ejb-relationship-role-name>Departments may have many Contacts</ejb-relationship-role-name>
<multiplicity>One</multiplicity>
<relationship-role-source>
<ejb-name>Departments</ejb-name>
</relationship-role-source>
<cmr-field>
<cmr-field-name>contacts_department_key</cmr-field-name>
<cmr-field-type>java.util.Collection</cmr-field-type>
</cmr-field>
</ejb-relationship-role>
<ejb-relationship-role>
<ejb-relationship-role-name>Contacts may have one Departments</ejb-relationship-role-name>
<multiplicity>Many</multiplicity>
<relationship-role-source>
<ejb-name>Contacts</ejb-name>
</relationship-role-source>
<cmr-field>
<cmr-field-name>departments_department_key</cmr-field-name>
</cmr-field>
</ejb-relationship-role>
</ejb-relation>
<ejb-relation>
<ejb-relation-name>Groups_join - Groups</ejb-relation-name>
<ejb-relationship-role>
<ejb-relationship-role-name>Groups may have many Groups_join</ejb-relationship-role-name>
<multiplicity>One</multiplicity>
<relationship-role-source>
<ejb-name>Groups</ejb-name>
</relationship-role-source>
<cmr-field>
<cmr-field-name>groups_join_group_key</cmr-field-name>
<cmr-field-type>java.util.Collection</cmr-field-type>
</cmr-field>
</ejb-relationship-role>
<ejb-relationship-role>
<ejb-relationship-role-name>Groups_join has one Groups</ejb-relationship-role-name>
<multiplicity>Many</multiplicity>
<relationship-role-source>
<ejb-name>Groups_join</ejb-name>
</relationship-role-source>
<cmr-field>
<cmr-field-name>groups_group_key</cmr-field-name>
</cmr-field>
</ejb-relationship-role>
</ejb-relation>
<ejb-relation>
<ejb-relation-name>Groups_join - Users</ejb-relation-name>
<ejb-relationship-role>
<ejb-relationship-role-name>Users may have many Groups_join</ejb-relationship-role-name>
<multiplicity>One</multiplicity>
<relationship-role-source>
<ejb-name>Users</ejb-name>
</relationship-role-source>
<cmr-field>
<cmr-field-name>groups_join_user_key</cmr-field-name>
<cmr-field-type>java.util.Collection</cmr-field-type>
</cmr-field>
</ejb-relationship-role>
<ejb-relationship-role>
<ejb-relationship-role-name>Groups_join may have one Users</ejb-relationship-role-name>
<multiplicity>Many</multiplicity>
<relationship-role-source>
<ejb-name>Groups_join</ejb-name>
</relationship-role-source>
<cmr-field>
<cmr-field-name>users_user_key</cmr-field-name>
</cmr-field>
</ejb-relationship-role>
</ejb-relation>
<ejb-relation>
<ejb-relation-name>Users - Contacts</ejb-relation-name>
<ejb-relationship-role>
<ejb-relationship-role-name>Contacts may have many Users</ejb-relationship-role-name>
<multiplicity>One</multiplicity>
<relationship-role-source>
<ejb-name>Contacts</ejb-name>
</relationship-role-source>
<cmr-field>
<cmr-field-name>users_contact_key</cmr-field-name>
<cmr-field-type>java.util.Collection</cmr-field-type>
</cmr-field>
</ejb-relationship-role>
<ejb-relationship-role>
<ejb-relationship-role-name>Users has one Contacts</ejb-relationship-role-name>
<multiplicity>Many</multiplicity>
<relationship-role-source>
<ejb-name>Users</ejb-name>
</relationship-role-source>
<cmr-field>
<cmr-field-name>contacts_contact_key</cmr-field-name>
</cmr-field>
</ejb-relationship-role>
</ejb-relation>
</relationships>
</ejb-jar>
jbosscmp-jdbc.xml
<jbosscmp-jdbc>
<defaults>
<datasource>java:/SapdbDS</datasource>
<datasource-mapping>SapDB</datasource-mapping>
<create-table>false</create-table>
<remove-table>false</remove-table>
</defaults>
<enterprise-beans>
<entity>
<ejb-name>Status_ids</ejb-name>
<table-name>status_ids</table-name>
<cmp-field>
<field-name>status_id</field-name>
<column-name>status_id</column-name>
</cmp-field>
<cmp-field>
<field-name>descrip</field-name>
<column-name>descrip</column-name>
</cmp-field>
</entity>
<entity>
<ejb-name>Departments</ejb-name>
<table-name>departments</table-name>
<cmp-field>
<field-name>department_key</field-name>
<column-name>department_key</column-name>
</cmp-field>
<cmp-field>
<field-name>department_name</field-name>
<column-name>department_name</column-name>
</cmp-field>
<cmp-field>
<field-name>company_name</field-name>
<column-name>company_name</column-name>
</cmp-field>
</entity>
<entity>
<ejb-name>Contacts</ejb-name>
<table-name>contacts</table-name>
<cmp-field>
<field-name>contact_key</field-name>
<column-name>contact_key</column-name>
</cmp-field>
<cmp-field>
<field-name>first_nm</field-name>
<column-name>first_nm</column-name>
</cmp-field>
<cmp-field>
<field-name>last_nm</field-name>
<column-name>last_nm</column-name>
</cmp-field>
<cmp-field>
<field-name>address</field-name>
<column-name>address</column-name>
</cmp-field>
<cmp-field>
<field-name>zip_code</field-name>
<column-name>zip_code</column-name>
</cmp-field>
<cmp-field>
<field-name>country</field-name>
<column-name>country</column-name>
</cmp-field>
<cmp-field>
<field-name>phone1</field-name>
<column-name>phone1</column-name>
</cmp-field>
<cmp-field>
<field-name>phone2</field-name>
<column-name>phone2</column-name>
</cmp-field>
<cmp-field>
<field-name>email</field-name>
<column-name>email</column-name>
</cmp-field>
<cmp-field>
<field-name>department_key</field-name>
<column-name>department_key</column-name>
</cmp-field>
<cmp-field>
<field-name>age</field-name>
<column-name>age</column-name>
</cmp-field>
</entity>
<entity>
<ejb-name>Groups</ejb-name>
<table-name>groups</table-name>
<cmp-field>
<field-name>group_key</field-name>
<column-name>group_key</column-name>
</cmp-field>
<cmp-field>
<field-name>group_name</field-name>
<column-name>group_name</column-name>
</cmp-field>
<cmp-field>
<field-name>date_add</field-name>
<column-name>date_add</column-name>
</cmp-field>
<cmp-field>
<field-name>date_avail</field-name>
<column-name>date_avail</column-name>
</cmp-field>
<cmp-field>
<field-name>date_expire</field-name>
<column-name>date_expire</column-name>
</cmp-field>
<cmp-field>
<field-name>status_id</field-name>
<column-name>status_id</column-name>
</cmp-field>
<cmp-field>
<field-name>descrip</field-name>
<column-name>descrip</column-name>
</cmp-field>
</entity>
<entity>
<ejb-name>Groups_join</ejb-name>
<table-name>groups_join</table-name>
<cmp-field>
<field-name>use_key</field-name>
<column-name>use_key</column-name>
</cmp-field>
<cmp-field>
<field-name>group_key</field-name>
<column-name>group_key</column-name>
</cmp-field>
</entity>
<entity>
<ejb-name>Users</ejb-name>
<table-name>users</table-name>
<cmp-field>
<field-name>user_key</field-name>
<column-name>user_key</column-name>
</cmp-field>
<cmp-field>
<field-name>username</field-name>
<column-name>username</column-name>
</cmp-field>
<cmp-field>
<field-name>password</field-name>
<column-name>password</column-name>
</cmp-field>
<cmp-field>
<field-name>contact_key</field-name>
<column-name>contact_key</column-name>
</cmp-field>
<cmp-field>
<field-name>group_key</field-name>
<column-name>group_key</column-name>
</cmp-field>
<cmp-field>
<field-name>status_id</field-name>
<column-name>status_id</column-name>
</cmp-field>
<cmp-field>
<field-name>date_add</field-name>
<column-name>date_add</column-name>
</cmp-field>
<cmp-field>
<field-name>date_avail</field-name>
<column-name>date_avail</column-name>
</cmp-field>
<cmp-field>
<field-name>date_expire</field-name>
<column-name>date_expire</column-name>
</cmp-field>
</entity>
</enterprise-beans>
</jbosscmp-jdbc>
jboss.xml
<jboss>
<session>
<ejb-name>MySessionEJB</ejb-name>
<ejb-ref>
<ejb-ref-name>Status_ids</ejb-ref-name>
<jndi-name>Status_ids</jndi-name>
</ejb-ref>
</session>
<entity>
<ejb-name>Status_ids</ejb-name>
<jndi-name>Status_ids</jndi-name>
<resource-ref>
<res-ref-name>jdbc/SapdbDS</res-ref-name>
<resource-name>SapDB</resource-name>
</resource-ref>
</entity>
<entity>
<ejb-name>Contacts</ejb-name>
<jndi-name>Contacts</jndi-name>
<resource-ref>
<res-ref-name>jdbc/SapdbDS</res-ref-name>
<resource-name>SapDB</resource-name>
</resource-ref>
</entity>
<entity>
<ejb-name>Departments</ejb-name>
<jndi-name>Departments</jndi-name>
<resource-ref>
<res-ref-name>jdbc/SapdbD</res-ref-name>
<resource-name>SapDB</resource-name>
</resource-ref>
</entity>
<entity>
<ejb-name>Groups</ejb-name>
<jndi-name>Groups</jndi-name>
<resource-ref>
<res-ref-name>jdbc/SapdbDS</res-ref-name>
<resource-name>SapDB</resource-name>
</resource-ref>
</entity>
<entity>
<ejb-name>Groups_join</ejb-name>
<jndi-name>Groups_join</jndi-name>
<resource-ref>
<res-ref-name>jdbc/SapdbDS</res-ref-name>
<resource-name>SapDB</resource-name>
</resource-ref>
</entity>
<entity>
<ejb-name>Users</ejb-name>
<jndi-name>Users</jndi-name>
<resource-ref>
<res-ref-name>jdbc/SapdbDS</res-ref-name>
<resource-name>SapDB</resource-name>
</resource-ref>
</entity>
</jboss>
package mypackage6.impl;
import javax.ejb.EntityBean;
import javax.ejb.EntityContext;
import javax.ejb.CreateException;
import mypackage6.DepartmentsLocal;
import java.util.Collection;
public abstract class ContactsBean implements EntityBean {
private EntityContext context;
public String ejbCreate(String contact_key, String email) throws CreateException {
setContact_key(contact_key);
setEmail(email);
return contact_key;
}
.....
package mypackage6.impl;
import javax.ejb.EntityBean;
import javax.ejb.EntityContext;
import javax.ejb.CreateException;
import java.util.Collection;
public abstract class DepartmentsBean implements EntityBean {
private EntityContext context;
public String ejbCreate(String department_key, String department_name, String company_name) throws CreateException {
setDepartment_key(department_key);
setDepartment_name(department_name);
setCompany_name(company_name);
return department_key;
}
.....
package mypackage6.impl;
import javax.ejb.EntityBean;
import javax.ejb.EntityContext;
import javax.ejb.CreateException;
import mypackage6.Groups_joinPK;
import mypackage6.GroupsLocal;
import mypackage6.UsersLocal;
public abstract class Groups_joinBean implements EntityBean {
private EntityContext context;
public Groups_joinPK ejbCreate(UsersLocal users_user_key, GroupsLocal groups_group_key) throws CreateException{
setUsers_user_key(users_user_key);
setGroups_group_key(groups_group_key);
return new Groups_joinPK( users_user_key.getUser_key(), groups_group_key.getGroup_key());
}
.....
package mypackage6.impl;
import javax.ejb.EntityBean;
import javax.ejb.EntityContext;
import javax.ejb.CreateException;
import java.sql.Timestamp;
import java.util.Collection;
public abstract class GroupsBean implements EntityBean {
private EntityContext context;
public String ejbCreate(String group_key, String group_name, Timestamp date_add, String status_id) throws CreateException {
setGroup_key(group_key);
setGroup_name(group_name);
setDate_add(date_add);
setStatus_id(status_id);
return group_key;
}
....
package mypackage6.impl;
import javax.ejb.EntityBean;
import javax.ejb.EntityContext;
import javax.ejb.CreateException;
import java.sql.Timestamp;
import mypackage6.ContactsLocal;
import java.util.Collection;
public abstract class UsersBean implements EntityBean {
private EntityContext context;
public String ejbCreate(String user_key, String username, String password, String status_id, Timestamp date_add, ContactsLocal contacts_contact_key) throws CreateException {
setUser_key(user_key);
setUsername(username);
setPassword(password);
setStatus_id(status_id);
setDate_add(date_add);
setContacts_contact_key(contacts_contact_key);
return user_key;
}
.....
package mypackage6;
import javax.ejb.EJBLocalHome;
import javax.ejb.CreateException;
import javax.ejb.FinderException;
import java.util.Collection;
public interface ContactsLocalHome extends EJBLocalHome {
ContactsLocal findByPrimaryKey(String primaryKey) throws FinderException;
Collection findAll() throws FinderException;
ContactsLocal create(String contact_key, String email) throws CreateException;
}
.....
package mypackage6;
import javax.ejb.EJBLocalHome;
import javax.ejb.CreateException;
import javax.ejb.FinderException;
import java.util.Collection;
public interface DepartmentsLocalHome extends EJBLocalHome {
DepartmentsLocal findByPrimaryKey(String primaryKey) throws FinderException;
Collection findAll() throws FinderException;
DepartmentsLocal create(String department_key, String department_name, String company_name) throws CreateException;
}
......
package mypackage6;
import javax.ejb.EJBLocalHome;
import javax.ejb.CreateException;
import javax.ejb.FinderException;
import java.util.Collection;
public interface Groups_joinLocalHome extends EJBLocalHome {
Groups_joinLocal findByPrimaryKey(Groups_joinPK primaryKey) throws FinderException;
Collection findAll() throws FinderException;
Groups_joinLocal create(UsersLocal users_user_key, GroupsLocal groups_group_key) throws CreateException;
}
...
package mypackage6;
import java.io.Serializable;
public class Groups_joinPK implements Serializable {
public String group_key;
public String user_key;
public Groups_joinPK(String user_key, String group_key) {
this.user_key = user_key;
this.group_key = group_key;
}
public void setGroup_key(String group_key) {
this.group_key = group_key;
}
public String getGroup_key() {
return this.group_key;
}
public void setUser_key(String user_key) {
this.user_key = user_key;
}
public String getUser_key() {
return this.user_key;
}
public boolean equals(Object other) {
if (other instanceof Groups_joinPK) {
final Groups_joinPK otherGroups_joinPK = (Groups_joinPK)other;
return (group_key.equals(otherGroups_joinPK.group_key) && user_key.equals(otherGroups_joinPK.user_key));
}
return false;
}
public int hashCode() {
// Add custom hashCode() impl here
return group_key.concat(user_key).hashCode();
}
}
....
package mypackage6;
import javax.ejb.EJBLocalHome;
import javax.ejb.CreateException;
import javax.ejb.FinderException;
import java.util.Collection;
import java.sql.Timestamp;
public interface GroupsLocalHome extends EJBLocalHome {
GroupsLocal findByPrimaryKey(String primaryKey) throws FinderException;
Collection findAll() throws FinderException;
GroupsLocal create(String group_key, String group_name, Timestamp date_add, String status_id) throws CreateException;
}
....
package mypackage6;
import javax.ejb.EJBLocalHome;
import javax.ejb.CreateException;
import javax.ejb.FinderException;
import java.util.Collection;
import java.sql.Timestamp;
public interface UsersLocalHome extends EJBLocalHome {
UsersLocal findByPrimaryKey(String primaryKey) throws FinderException;
Collection findAll() throws FinderException;
UsersLocal create(String user_key, String username, String password, String status_id, Timestamp date_add, ContactsLocal contacts_contact_key) throws CreateException;
}