class A
{
Set bs;
...
public void addB(B b)
{
ibs.add(b);
if (! b.getAs().contains(this)) b.addA(this);
}
}-Brian
On Dec 15, 2003, at 6:03 PM, Tino Sch�llhorn wrote:
Hi there,
this is a topic which is not specifically bound to ojb - but since there are a lot of users out there who might have the same problem (and hopefully a solution) I post this message here:
I have several classes which I use to map tables to objects. Now I am wondering what the most appropriate design pattern for "referential integrity" is. An example. Suppose we have two classes which implement a N:M-Relation:
class A { Collection bs; void addB(B b) { bs.add(b); }
void removeB(B b) { bs.remove(b); } }
// the class B is the same as above.
Now I'd like to use these classes. But there is one problem: When using these simple classes I have to write:
A a = new A(); B b = new B(); a.addB(b); b.addA(a);
so that one can navigate from both instances to each other. But I juest want to write:
a.addB(b);
And the changes should also be reflected in object b.
Does anyone know a design pattern for this (quite common) problem?
Tino
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
