Shiv,

You raise a good point on Addresses if they are shared in your design.

But for phone numbers you might design a flexible model for handling many
different numbers (e.g. business, home, mobile, fax, cottage...). Why hard
code the slots in the parent object when you could have a collection of
phone numbers instead? IMHO, phone numbers are a great example for dependent
objects...

Regards,

-Chris.

> -----Original Message-----
> From: Shiv Kumar [SMTP:[EMAIL PROTECTED]]
> Sent: Tuesday, July 11, 2000 10:41 AM
> To:   [EMAIL PROTECTED]
> Subject:      Entity bean questions
>
> Hi all
>
> 1. What is a good example of 'dependant object'? The spec gives an
>    example of employee record. It says an employee record should be
>    modelled as entity beans, but employee address and phone number
>    should not be.
>
>      * What if all employee addresses are maintained in a different
>        table in the db?
>
>      * And phone number of course will be a field in my EB. Why should I
>        ever model it as a dependant object?
>
>    I think, dependant objects are only useful when used with SBs.  With
>    EB, I am not sure where it will be useful. Because, with CMP bean,
>    all fields that will be stored in db should be declared public. I can
>    not, for example, have :
>
>        public MyClass myObject;
>
>    where, MyClass is a dependant object
>
>        class MyClass { public int x; public int y }
>
>    and in my deployment descriptor,
>
>        <cmp-field>
>          <field-name>myObject.x</field-name>
>        </cmp-field>
>        <cmp-field>
>          <field-name>myObject.y</field-name>
>        </cmp-field>
>
>    At least WebLogic 5.1 did not provide this feature.
>
>    In one case, my entity bean represented a table which had 20 columns.
>    Instead of taking all 20 params in ejbCreate() method, I had a helper
>    class which encapsulated these columns :
>
>        class Columns implements java.io.Serializable {
>        }
>
>        // MyHome.java
>        public MyRemote create(Columns cols) throws ...
>
>    Because of the stupid restriction that all persistable data members
>    should be declared in the bean class, I end up duplicated all data
>    members of 'class Columns' in my bean's class, like :
>
>        // MyBean.java
>        public Columns cols;
>
>        public MyPK ejbCreate(Columns cols) throws ... {
>            this.m = cols.m;
>            this.n = cols.n;
>            this.o = cols.o;
>            this.p = cols.p;
>            this.x = cols.x;
>            this.y = cols.y;
>            this.z = cols.z;
>        }
>
>    instead of simply doing,
>
>        public MyPK ejbCreate(Columns cols) throws ... {
>            if (cols != null) this.cols = cols
>        }
>
>
> 2. I was never successfully able to model a EB which refers to another
>    EB like,
>
>        // CompanyBean.java
>        class CompanyBean {
>            public int id; // PK
>            public int name;
>        }
>
>        // UserBean.java
>        class UserBean {
>            public int id; // PK
>            public String name;
>            public Company company;
>        }
>
>    I had to always use 'public int companyID' and rely on the
>    constraints provided by the underlying db.
>
> BTW, I was always using WebLogic 5.1. I would like to know how other
> containers solve this problem.
>
> TIA.
> --
> shiv
> [EMAIL PROTECTED]
>
>
>
> __________________________________________________
> Do You Yahoo!?
> Talk to your friends online with Yahoo! Messenger.
> http://im.yahoo.com
>
> ==========================================================================
> =
> 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".

Reply via email to