Well, here's an example of a parent-child 1->N relationship:

A has a Set member field of type B

The class outlines are:

public interface A extends EJBObject
{
  public Set getB() throws RemoteException;
  ...
}

public interface B extends EJBObject
{
  ...
}

public class AEJB implements EntityBean
{
  public static final Class b_types = B.class; //required by Orion I think
  public Set b;

  public Set getB()
  {
    return b;
  }
  
  ...
}

public class BEJB implements EntityBean
{
  ...
}

That models the relationship using entity beans and CMP

Next you'll need to specify all this in the ejb-jar.xml, here are the
relevant sections:

<ejb-jar>
  <enterprise-beans>
    <entity>
      <!-- all attributes for bean A -->
      <cmp-field>
        <description>A set of B</description>
        <field-name>b</field-name>
      </cmp>
    </entity>
    <!-- rest of ejb-jar file, with attributes for entity B -->
  </enterprise-beans>
  <relationships>
    <ejb-relation>
      <ejb-relation-name>A-B</ejb-relation-name>
      <ejb-relationship-role>
        <ejb-relationship-role-name>
          a-has-b
        </ejb-relationship-role-name>
        <multiplicity>one</multiplicity>
        <role-source>
          <ejb-name>A</ejb-name>
        </role-source>
        <cmr-field>
          <cmr-field-name>b</cmr-field-name>
          <cmr-field-type>java.util.Set</cmr-field-type>
        </cmr-field>
      </ejb-relationship-role>
      <ejb-relationship-role>
        <ejb-relationship-role-name>
          b-belongsto-a
        </ejb-relationship-role-name>
        <multiplicity>many</multiplicity>
        <role-source>
          <ejb-name>B</ejb-name>
        </role-source>
      </ejb-relationship-role>
    </ejb-relation>
  </relationships>
</ejb-jar>   

When you deploy this, Orion will automatically create all the appropriate
entries in orion-ejb-jar.xml, including datasource, database field
and table names, and so on. You can then tweak it further to fit your
needs. I hope you find this helpful...

Hani

 On Mon, 13 Nov 2000, Juan Gargiulo wrote:

> Hi,
> 
> I'm having problems configuring orion to create the tables for entity EJBs
> with references to other entity EJBs (using CMP). Can somebody, please,
> enumerate the steps for doing this.
> 
> Thanks in advance,
> 
> Juan Gargiulo
> 
> 
> 


Reply via email to