(Pardon me if this is sent twice, my first attempt gave me a strange error
from my SMTP server...)

I agree that we are talking about implementation-specific details that I
shouldn't be overly worried about.  But I did think of some additional
information that may be relevant.

At 11:18 PM 8/27/01 -0700, Cedric Beust wrote:
>[Responses inline.  I tried to trim but I thought I should keep the
>entirety of
>David's explanations for clarity]
>
> > From: A mailing list for Enterprise JavaBeans development
> > [mailto:[EMAIL PROTECTED]]On Behalf Of David Levine
>
> > <ejb-relation>
> >   <ejb-relation-name>GroupUser</ejb-relation-name>
> >   <ejb-relationship-role>
> >     <ejb-relationship-role-name>GroupHasUsers</ejb-relationship-role-name>
> >     <multiplicity>One</multiplicity>
> >     <relationship-role-source>
> >       <ejb-name>Group</ejb-name>
> >     </relationship-role-source>
> >   </ejb-relationship-role>
> >   <ejb-relationship-role>
> >     <ejb-relationship-role-name>UserInGroup</ejb-relationship-role-name>
> >     <multiplicity>Many</multiplicity>
> >     <relationship-role-source>
> >       <ejb-name>User</ejb-name>
> >     </relationship-role-source>
> >     <cmr-field>
> >       <cmr-field-name>group</cmr-field-name>
> >     </cmr-field>
> >   </ejb-relationship-role>
> > </ejb-relation>
> >
>
>I can't see anything wrong with the deployment descriptor you posted, what
>error
>are you seeing?

I haven't gotten as far as deployment, so no errors, yet!  :)

The alternative way of doing this might be:

<ejb-relation>
   <ejb-relation-name>GroupUser</ejb-relation-name>
   <ejb-relationship-role>
     <ejb-relationship-role-name>GroupHasUsers</ejb-relationship-role-name>
     <multiplicity>One</multiplicity>
     <relationship-role-source>
       <ejb-name>Group</ejb-name>
     </relationship-role-source>
     <cmr-field>
       <cmr-field-name>users</cmr-field-name>
       <cmr-field-type>java.util.Collection</cmr-field-type>
     </cmr-field>
   </ejb-relationship-role>
   <ejb-relationship-role>
     <ejb-relationship-role-name>UserInGroup</ejb-relationship-role-name>
     <multiplicity>Many</multiplicity>
     <relationship-role-source>
       <ejb-name>User</ejb-name>
     </relationship-role-source>
   </ejb-relationship-role>
</ejb-relation>

Note that this also accomplishes a unidirectional one-to-many situation: a
Group has many Users, with each User belonging to only one Group (although
the User does not actually have a reference to the Group).  This second
situation is what I usually see in examples.  But it seems to me that my
first deployment descriptor, with the cmr-field in User instead of in
Group, is more efficient, especially if I will never be asking Group for a
list of its Users, but instead just want to know what Group a specific User
belongs to.

I know this second deployment descriptor is legal, since I have seen
examples of it.  But I haven't seen an example of the first descriptor I
offered, yet.  In my original example, the User bean needed setGroup and
getGroup accessors.  Since the Group only had a Local interface, I needed a
GroupView object for a client to be able to ask the User what Group they
belonged to.  Using the second deployment descriptor, things would be
reversed: the Group would be able to get and set its collection of Users,
and it is the User that would need the Local interface (and the Group would
have to pass a collection of UserView objects to the client, rather than
the Local interfaces).  I'll probably just try it both ways and see what
happens.

Thanks again!
David

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to