Hi All,
I am trying to learn CMR with JBoss. Using CMP I am able to deploy two ejbs Employee and Department without any relationship. After deployment container is creating two tables and I am able to insert data into these two table. Now I am wondering how I can enforce referential integrity between these two tables.I am bugged with few questions
1-How do I define relationship between these two tables.
2-Since I am creating tables while deployment, is it going to create relationship at DB level?
3-Will the JBoss container prevent if I try to enter an employee with a department that does not exist in the department table.

Here is my ejb-jar.xml

<!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>
   <ejb-name>Facade</ejb-name>
   <home>cmr.emp.FacadeHome</home>
   <remote>cmr.emp.Facade</remote>
   <local-home>cmr.emp.FacadeLocalHome</local-home>
   <local>cmr.emp.FacadeLocal</local>
   <ejb-class>cmr.emp.FacadeBean</ejb-class>
   <session-type>Stateless</session-type>
   <transaction-type>Container</transaction-type>
  </session>
  <entity>
   <ejb-name>Department</ejb-name>
   <local-home>cmr.emp.DepartmentHome</local-home>
   <local>cmr.emp.Department</local>
   <ejb-class>cmr.emp.DepartmentBean</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>Department</abstract-schema-name>
   <cmp-field>
    <field-name>deptCode</field-name>
   </cmp-field>
   <cmp-field>
    <field-name>deptName</field-name>
   </cmp-field>
   <cmp-field>
    <field-name>description</field-name>
   </cmp-field>
   <primkey-field>deptCode</primkey-field>
   <query>
    <query-method>
     <method-name>findByName</method-name>
     <method-params>
      <method-param>java.lang.String</method-param>
     </method-params>
    </query-method>
    <ejb-ql>
     <![CDATA[SELECT OBJECT(a) FROM Department AS a WHERE a.deptName = ?1]]>
    </ejb-ql>
   </query>
  </entity>

  <entity>
   <ejb-name>Employee</ejb-name>
   <local-home>cmr.emp.EmployeeHome</local-home>
   <local>cmr.emp.Employee</local>
   <ejb-class>cmr.emp.EmployeeBean</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>Employee</abstract-schema-name>
   <cmp-field>
    <field-name>empCode</field-name>
   </cmp-field>
   <cmp-field>
    <field-name>empName</field-name>
   </cmp-field>
   <cmp-field>
    <field-name>city</field-name>
   </cmp-field>
   <cmp-field>
    <field-name>deptCode</field-name>
   </cmp-field>
   <primkey-field>empCode</primkey-field>
   <query>
    <query-method>
     <method-name>findByName</method-name>
     <method-params>
      <method-param>java.lang.String</method-param>
     </method-params>
    </query-method>
    <ejb-ql>
     <![CDATA[SELECT OBJECT(a) FROM Employee AS a WHERE a.empName = ?1]]>
    </ejb-ql>
   </query>
  </entity>
 </enterprise-beans>
</ejb-jar>

Thanks in advance.
Gautham