Hi Janne,
the relationship can be handled at the database level. You can have for
example two fields "isDirty" in the Artist and Cd tables.
Everytime you update one of the two BMPs you put the flags "isDirty" to
"True" in the 2 tables.
Now the 2 BMPs can be modified as following :
> Cd {
> private Artist artist;
> private boolean artistLoaded;
>
> setArtist(Artist);
> Artist getArtist();
boolean isDirty(); // check the isDirty field in the Cd table
reload(); // reload the BMP
> }
> Artist {
> private Collection cds;
> private boolean cdsLoaded;
>
> setCds(Collection cds);
> Collection getCds();
boolean isDirty(); // check the isDirty field in the Cd table
reload(); // reload the BMP
> }
Now for each attribute X of a BMP you should start the getX method by
something like "if isDirty() then relaod();"
Of course, in this case all your business methods should access the BMP
fields by their getter methods and not directly (for example every method in
the BMP Cd should call the Cd.getArtist() instead of Cd.artist);
I'm not sure however that's the best solution from the performance point of
view!
anyway hope it helps!
Amine
> -----Message d'origine-----
> De : Janne Mattila [mailto:[EMAIL PROTECTED]
> Envoy� : mardi 26 ao�t 2003 11:32
> � : [EMAIL PROTECTED]
> Objet : BMP relationships
>
>
> Hi,
>
> what's the correct way to handle BMP relationships? I have a scenario:
>
> Cd {
> private Artist artist;
> private boolean artistLoaded;
>
> setArtist(Artist);
> Artist getArtist();
> }
>
> Artist {
> private Collection cds;
> private boolean cdsLoaded;
>
> setCds(Collection cds);
> Collection getCds();
> }
>
> Now, I would implement this so that the relationship fields
> (Cd.artist and
> Artist.cds) are lazy loaded. Calling set() -methods would
> update both the
> object and the parameter object, ie. bornInTheUsa.setArtist
> (bruceSpringsteen) would update both bornInTheUsa.artist field AND
> bruceSpringsteen.cds collection (otherwise bruceSpringsteen will have
> invalid state after the call).
>
> Is this the right way to go? Plus, can I trust that in clustered
> environment also EJB's in other instances are updated? So
> that there is not
> an invalid artist bean in some instance having
> bruceSpringsteen.cds missing
> the bornInTheUsa?
>
> ==============================================================
> =============
> 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".