Are we talking inheritance hierarchy or hierarchy of heterogeneous
object types? or just plain old "this object of type A has an
association with another object of type A"? I am assuming the latter,
in which case I think your first suggestion is the way to go. Usually I
would define the table such that one column is a "parent_id" (or
"child_id" depending on how you want to emphasize the relationship) that
is set to the value of the primary key id for the parent (i.e. the table
has a foreign key on itself). The top-most level of parents in this
hierarchy have NULLs for their parent_ids.
This method is very extensible as the number of levels in the hierarchy
are unlimited - your second suggestion requires a new table every time
you add a new level in the hierarchy.
You can obtain the value for the persistent parentId field from the
parent bean's remote reference passed in as an arg to setParentID(), or
at ejbCreate() time, or whatever.
I am also trying to remember if anything special happens if you keep a
reference to another bean as an instance variable in another bean - I
don't think there is anything, at least nothing obvious I can find in
the literature. Anyone?
Greg Pierce wrote:
>
> Interesting question for you folks. Okay, I have an EJB that has hierarchy
> within it and I want to use JAWS to deploy it. During my experiments this
> weekend I came up with 2 ways to represent this hierarchy:
>
> 1) Build one table that represents the entire object hierarchy chain such
> that any object can have a single record in the table.
>
> 2) Build a table for each one of the objects in the hierarchy and add a
> bunch of methods to perform lookups within the hierarchy for parent and
> child classes.
>
> If I am building a system with JAWS, and assuming that the system may change
> - which approach seems to make the most sense? At the moment I am leaning
> towards building a single table rather that doing a leaf node
> implementation.
>
> --
> --------------------------------------------------------------
> To subscribe: [EMAIL PROTECTED]
> To unsubscribe: [EMAIL PROTECTED]
> Problems?: [EMAIL PROTECTED]
--
Jeffrey & Nikole Bonevich
Maxmillian Bonevich
Ann Arbor, Michigan
[EMAIL PROTECTED]
http://www.bonevich.com
--
--------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Problems?: [EMAIL PROTECTED]