OrgUnits should point back to the Organization entity bean instance. You
have two classes referencing each other.
Do not use references or handles, the EJB server might replace them with
a different instance so an OrgUnit might point to a different
Organization at different times.
Although this should never be a problem (at least not in this example),
you might have some dependency there at the point of load/store that
might break.
arkin
Laird Nelson wrote:
>
> Not the usual, I promise.
>
> I have an Organization. It is an EntityBean. It wholly contains
> OrgUnits. They are not enterprise beans since they are dependent
> objects, and since it appears like a Good Thing to reduce the number of
> EntityBeans needed in an architecture.
>
> But now each OrgUnit logically needs a reference back to the
> Organization that owns it. Can I simply keep a reference to the
> Organization that creates an OrgUnit? Should I store the handle
> instead? Or the OrganizationHome? Or what?
>
> Sample, shortened code follows:
>
> // Remote reference for OrganizationBean class--
> // the OrganizationBean class implements EntityBean.
> public interface Organization extends EJBObject {
> public OrgUnit[] getOrgUnits();
> }
>
> public class OrgUnit {
>
> // OK? Bad? Organization is an EJBObject.
> // Does this matter?
> private Organization org = null;
>
> public OrgUnit(Organization org) {
> super();
> this.org = org; // OK? Bad?
> }
>
> public Organization getOrganization() {
> return this.org; // OK? Bad?
> }
>
> }
>
> Cheers,
> Laird
>
> ===========================================================================
> 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".
--
----------------------------------------------------------------------
Assaf Arkin www.exoffice.com
CTO, Exoffice Technologies, Inc. www.exolab.org
===========================================================================
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".