An Object providing an interface to seach it's own kinds is not really a
good idea (unless it is an intialization, e.g., findByPrimaryKey or
something similar)
Your data model for MxN association is perfect with three tables PERSON,
AWARD and PERSON_AWARD.
(even with1-N association)
To get all the awards for a person, one first has to get to the person (i.e
identify the person), which will be accomplished by the PersonBean and
findByPrimaryKey(). Now you have two options, one is to expose the
PersonBean to the Awards and provide a getAwards() interface in the
PersonBaen itselt, the other is to provide a session bean to do the same.
PersonAward is something that represents an association which should provide
a create interface with person and award as arguments ( to be able to add
new awards to a person), if required.
vela
----- Original Message -----
From: Shawn McKisson <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, October 14, 1999 3:16 PM
Subject: Re: I'm not understanding EBs.
> Pankaj Tandon wrote:
> >
> > The fact that you have defined an MxN relationship between AWARDS and
> > PEOPLE means that you will eventually need to support a method such as
> > Enumeration findPeopleForAward(Award a) ; in addition to
> > findAwardsByPerson();
> > If that is the case I think you will need an entity eJB called
> > PersonAwardBean which implements *both* these business methods and is
> > persisted in the PERSON_AWARD table.
> >
> > If however, you only need to implement findAwardsByPerson(); then you
dont
> > really need the PERSON_AWARD table. You will need a foreign key in the
> > AWARDS table referecing the person table. (at db level, that's an
option)
> > and will need one entity eJB for each PERSON and AWARD table, most
likely
> > doing the 'join' in your session bean (The session bean will invoke
finder
> > methods on each bean). Unless someone can suggest how to write an entity
> > bean for 2 tables connected by a foreign key....
>
> Ah, very helpful indeed!
>
> You are correct in proposing that what I really want is a 1 - N mapping of
> people to awards. I am going to code up the three beans, as you suggested
in the
> latter part of your mail, and see how things go.
>
> I would still be interested to hear from anyone could suggest how to
accomplish
> this all in one bean (which I guess is what I was (ignorantly) originally
trying
> to do.)
> Mabye someone has an argument as to why or why not to do it that way?
>
> Thank you for your insight.
>
> --shawn
>
>
===========================================================================
> 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".
>
>
===========================================================================
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".