Hi Edward,
thank you for your reply.
The query to find people who have a certain role would be used frequently,
so following your advice i should "maintain the appropriate foreign keys
and implement personHome.findByRole()"
erm, this leaves me with one small problem...I don't know what you mean
by maintaining foreign keys. :-)
I understand the foreing keys (in this example) are the keys of all the
roles.
But other then that you've lost me...could you explain this in more
detail? thnx.
And yes I agree with you on not using Bi-directonal associations.
-Alexander.
Kenworthy, Edward wrote:
> Hi Alexander
>
> Depends on how frequently you do "gives me all persons who have the role of
> "Instructor"?"
>
> If it's infrequently then don't implement an association from role-->person.
> Instead just implement person-->role and then provide a method on role of
> getAllPeople(). The *implementation* of which does a personHome.findAll()
> for each person if role == this then add to list of matching persons.
>
> If you do such a query frequently, or its time sensitive, then you'll have
> to maintain the appropriate foreign keys and implement
> personHome.findByRole(). But this means you have to maintain the foreign
> key.
>
> Basically maintaining bi-directional associations is a pain so avoid them if
> you can.
>
> Hope this helps.
>
> Edward
>
> -----Original Message-----
> From: Alexander ten Bruggencate [mailto:[EMAIL PROTECTED]]
> Sent: 20 December 2000 11:54
> To: jBoss user mailing list
> Subject: [jBoss-User] design quesion
>
>
> Hi all,
>
> before i spend a lot of time implementing something which might not work
> I want to know what the best way is to design something like the following:
>
> In my application a person can have multiple roles, for example a person
> can be an "Instructor" and/or a "Coordinator".
>
> Which leads to something like
> Role[] person.getRoles(); and
> bool person.hasRole("Instructor");
>
> but how do i design something that easily gives me all persons who have
> the role of "Instructor"?
> Is the best way for this to define a finder in RoleHome? e.g.
> roleHome.findByPerson(...)?
>
> well if someony has a working design for this I would like to know how
> it looks like...
>
> thnx,
> -Alexander.
>
>
>
> --
> --------------------------------------------------------------
> To subscribe: [EMAIL PROTECTED]
> To unsubscribe: [EMAIL PROTECTED]
> List Help?: [EMAIL PROTECTED]
>
>
> --
> --------------------------------------------------------------
> To subscribe: [EMAIL PROTECTED]
> To unsubscribe: [EMAIL PROTECTED]
> List Help?: [EMAIL PROTECTED]
>
>
>
--
--------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
List Help?: [EMAIL PROTECTED]