1 Reply Latest reply on Jun 10, 2005 11:54 AM by schmidts

    EJB Relationsship for remote and local interfaces

    monecke

      Hello,

      sorry if this FAQ, i have searched with no satifised result, probaly wrong search words..

      I use JBoss 4.0 and ejb 2 and cmp.

      I have two entities Project (classes: ProjectLocal, ProjectLocalHome, ProjectEJB) and User (classes: UserLocal, UserLocalHome, UserEJB). The one to many releationsship between both is "project has responsible user".
      Modelling all with local interface is no problem an works fine. I have added

      public abstract UserLocal getResponsible();
      public abstract void setResponsible(UserLocal user);

      to the local interface ProjectLocal.

      Here is an extract of my ejb-jar.xml
      <relationships>
       <ejb-relation>
       <ejb-relation-name>Project-User</ejb-relation-name>
       <ejb-relationship-role>
       <ejb-relationship-role-name>project-has-responsible-user</ejb-relationship-role-name>
       <multiplicity>Many</multiplicity>
       <relationship-role-source>
       <ejb-name>ProjectEJB</ejb-name>
       </relationship-role-source>
       <cmr-field>
       <cmr-field-name>responsible</cmr-field-name>
       </cmr-field>
       </ejb-relationship-role>
       <ejb-relationship-role>
       <ejb-relationship-role-name>user-is-responsible-for-project</ejb-relationship-role-name>
       <multiplicity>One</multiplicity>
       <relationship-role-source>
       <ejb-name>UserEJB</ejb-name>
       </relationship-role-source>
       </ejb-relationship-role>
       </ejb-relation>
       </relationships>


      No problem at all. Works fine.

      Now i added for both entities a remote interface and home. Opps? What should i do with the cmr-field reponsible. I can't change the return type of the function getResponsible.
      Should i duplicate all the stuff and added a new cmr-field responsible? I don't think so, but how could i handle this? Is there a design pattern or an example?

      If you need more code, please give me a hint.

      Thanks in advance,

      Lars.