Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 » update problem with Bidirectional composite aggregation
update problem with Bidirectional composite aggregation [message #473071] Thu, 31 May 2007 22:55 Go to next message
Pradeep is currently offline PradeepFriend
Messages: 54
Registered: July 2009
Member
Hi,

When I have bi-directional associations, if I update oneside otherside is
automatically getting updated.

Does it anyway differ if I one side of the relationship is composition.

i.e

A contains a list of Bs, and Each B has a reference to A.


class A {

// I set the association to composite aggregation.
EList<B> bs;
}

class B {
A a;
}

Now, I am forced to update both the objects. Otherwise it is resulting in
NullPointerExeception.

Thanks
Pradeep
Re: update problem with Bidirectional composite aggregation [message #473081 is a reply to message #473071] Fri, 01 June 2007 15:01 Go to previous messageGo to next message
james bruck is currently offline james bruckFriend
Messages: 1724
Registered: July 2009
Senior Member
Hi Pradeep,

You can make your composition association navigable in one way by doing the
following...

Create a class call it "Class1".
Create a class call it "Class2".
Create an association call it "A".
Create a property under Class1.
Set the aggregation to composite.
Set the association to "A".
Set its type to Class2.
Set multiplicity .
Create a property under "A"
Set its type to Class1.
Set its association to "A"
Set its aggregation to "none"
For association "A"
Set the Member ends to the two newly created properties.


When you convert that to .ecore you should see..
Class1 with EReference of type Class2.
Class2.

It sounds like that is what you want to do.

Regards,

- James.


"Pradeep" <eclipseuser123@yahoo.com> wrote in message
news:f3njpp$jm2$1@build.eclipse.org...
> Hi,
>
> When I have bi-directional associations, if I update oneside otherside is
> automatically getting updated.
>
> Does it anyway differ if I one side of the relationship is composition.
>
> i.e
>
> A contains a list of Bs, and Each B has a reference to A.
>
>
> class A {
>
> // I set the association to composite aggregation.
> EList<B> bs;
> }
>
> class B {
> A a;
> }
>
> Now, I am forced to update both the objects. Otherwise it is resulting in
> NullPointerExeception.
>
> Thanks
> Pradeep
>
>
Re: update problem with Bidirectional composite aggregation [message #473082 is a reply to message #473071] Fri, 01 June 2007 15:39 Go to previous messageGo to next message
Kenn Hussey is currently offline Kenn HusseyFriend
Messages: 1620
Registered: July 2009
Senior Member
Pradeep,

Bidirectional compositions should not be a problem. I assume you set the
aggregation kind to 'composite' for just the owning end?

Kenn

"Pradeep" <eclipseuser123@yahoo.com> wrote in message
news:f3njpp$jm2$1@build.eclipse.org...
> Hi,
>
> When I have bi-directional associations, if I update oneside otherside is
> automatically getting updated.
>
> Does it anyway differ if I one side of the relationship is composition.
>
> i.e
>
> A contains a list of Bs, and Each B has a reference to A.
>
>
> class A {
>
> // I set the association to composite aggregation.
> EList<B> bs;
> }
>
> class B {
> A a;
> }
>
> Now, I am forced to update both the objects. Otherwise it is resulting in
> NullPointerExeception.
>
> Thanks
> Pradeep
>
>
Re: update problem with Bidirectional composite aggregation [message #473084 is a reply to message #473081] Fri, 01 June 2007 16:49 Go to previous messageGo to next message
Pradeep is currently offline PradeepFriend
Messages: 54
Registered: July 2009
Member
I did exactly the way James suggested earlier. My question is how do I get
bidirectional navigation in case of composite aggregation.

Yes, I did set the aggregation kind to composite just for the owned end.

But changing the other end to composite is not helping either.

i.e.

If I say

a.getBs().add(b)

and call b.getA() it is returning null.

Thanks
Pradeep



Pradeep,

Bidirectional compositions should not be a problem. I assume you set the
aggregation kind to 'composite' for just the owning end?

Kenn


"James Bruck" <jbruck@ca.ibm.com> wrote in message
news:f3pcbe$t50$2@build.eclipse.org...
> Hi Pradeep,
>
> You can make your composition association navigable in one way by doing
> the
> following...
>
> Create a class call it "Class1".
> Create a class call it "Class2".
> Create an association call it "A".
> Create a property under Class1.
> Set the aggregation to composite.
> Set the association to "A".
> Set its type to Class2.
> Set multiplicity .
> Create a property under "A"
> Set its type to Class1.
> Set its association to "A"
> Set its aggregation to "none"
> For association "A"
> Set the Member ends to the two newly created properties.
>
>
> When you convert that to .ecore you should see..
> Class1 with EReference of type Class2.
> Class2.
>
> It sounds like that is what you want to do.
>
> Regards,
>
> - James.
>
>
> "Pradeep" <eclipseuser123@yahoo.com> wrote in message
> news:f3njpp$jm2$1@build.eclipse.org...
>> Hi,
>>
>> When I have bi-directional associations, if I update oneside otherside is
>> automatically getting updated.
>>
>> Does it anyway differ if I one side of the relationship is composition.
>>
>> i.e
>>
>> A contains a list of Bs, and Each B has a reference to A.
>>
>>
>> class A {
>>
>> // I set the association to composite aggregation.
>> EList<B> bs;
>> }
>>
>> class B {
>> A a;
>> }
>>
>> Now, I am forced to update both the objects. Otherwise it is resulting in
>> NullPointerExeception.
>>
>> Thanks
>> Pradeep
>>
>>
>
>
Re: update problem with Bidirectional composite aggregation [message #473086 is a reply to message #473084] Fri, 01 June 2007 19:02 Go to previous message
james bruck is currently offline james bruckFriend
Messages: 1724
Registered: July 2009
Senior Member
If you want a bidirectional composite association then you need to do
something a bit different...
( I thought you really wanted a "one way navigable" composite association ).

Try this ...


Create a class call it "Class1".
Create a class call it "Class2".
Create an association call it "A".
Create a property under Class1.
Set the aggregation to composite.
Set the association to "A".
Set its type to Class2.
Set multiplicity .
Create a property under Class2
Set its type to Class1.
Set its association to "A"
Set its aggregation to "none"
For association "A"
Set the Member ends to the two newly created properties.



James.


"Pradeep" <eclipseuser123@yahoo.com> wrote in message
news:f3pin7$4oi$1@build.eclipse.org...
>
> I did exactly the way James suggested earlier. My question is how do I get
> bidirectional navigation in case of composite aggregation.
>
> Yes, I did set the aggregation kind to composite just for the owned end.
>
> But changing the other end to composite is not helping either.
>
> i.e.
>
> If I say
>
> a.getBs().add(b)
>
> and call b.getA() it is returning null.
>
> Thanks
> Pradeep
>
>
>
> Pradeep,
>
> Bidirectional compositions should not be a problem. I assume you set the
> aggregation kind to 'composite' for just the owning end?
>
> Kenn
>
>
> "James Bruck" <jbruck@ca.ibm.com> wrote in message
> news:f3pcbe$t50$2@build.eclipse.org...
> > Hi Pradeep,
> >
> > You can make your composition association navigable in one way by doing
> > the
> > following...
> >
> > Create a class call it "Class1".
> > Create a class call it "Class2".
> > Create an association call it "A".
> > Create a property under Class1.
> > Set the aggregation to composite.
> > Set the association to "A".
> > Set its type to Class2.
> > Set multiplicity .
> > Create a property under "A"
> > Set its type to Class1.
> > Set its association to "A"
> > Set its aggregation to "none"
> > For association "A"
> > Set the Member ends to the two newly created properties.
> >
> >
> > When you convert that to .ecore you should see..
> > Class1 with EReference of type Class2.
> > Class2.
> >
> > It sounds like that is what you want to do.
> >
> > Regards,
> >
> > - James.
> >
> >
> > "Pradeep" <eclipseuser123@yahoo.com> wrote in message
> > news:f3njpp$jm2$1@build.eclipse.org...
> >> Hi,
> >>
> >> When I have bi-directional associations, if I update oneside otherside
is
> >> automatically getting updated.
> >>
> >> Does it anyway differ if I one side of the relationship is composition.
> >>
> >> i.e
> >>
> >> A contains a list of Bs, and Each B has a reference to A.
> >>
> >>
> >> class A {
> >>
> >> // I set the association to composite aggregation.
> >> EList<B> bs;
> >> }
> >>
> >> class B {
> >> A a;
> >> }
> >>
> >> Now, I am forced to update both the objects. Otherwise it is resulting
in
> >> NullPointerExeception.
> >>
> >> Thanks
> >> Pradeep
> >>
> >>
> >
> >
>
>
Re: update problem with Bidirectional composite aggregation [message #619669 is a reply to message #473071] Fri, 01 June 2007 15:01 Go to previous message
james bruck is currently offline james bruckFriend
Messages: 1724
Registered: July 2009
Senior Member
Hi Pradeep,

You can make your composition association navigable in one way by doing the
following...

Create a class call it "Class1".
Create a class call it "Class2".
Create an association call it "A".
Create a property under Class1.
Set the aggregation to composite.
Set the association to "A".
Set its type to Class2.
Set multiplicity .
Create a property under "A"
Set its type to Class1.
Set its association to "A"
Set its aggregation to "none"
For association "A"
Set the Member ends to the two newly created properties.


When you convert that to .ecore you should see..
Class1 with EReference of type Class2.
Class2.

It sounds like that is what you want to do.

Regards,

- James.


"Pradeep" <eclipseuser123@yahoo.com> wrote in message
news:f3njpp$jm2$1@build.eclipse.org...
> Hi,
>
> When I have bi-directional associations, if I update oneside otherside is
> automatically getting updated.
>
> Does it anyway differ if I one side of the relationship is composition.
>
> i.e
>
> A contains a list of Bs, and Each B has a reference to A.
>
>
> class A {
>
> // I set the association to composite aggregation.
> EList<B> bs;
> }
>
> class B {
> A a;
> }
>
> Now, I am forced to update both the objects. Otherwise it is resulting in
> NullPointerExeception.
>
> Thanks
> Pradeep
>
>
Re: update problem with Bidirectional composite aggregation [message #619670 is a reply to message #473071] Fri, 01 June 2007 15:39 Go to previous message
Kenn Hussey is currently offline Kenn HusseyFriend
Messages: 1620
Registered: July 2009
Senior Member
Pradeep,

Bidirectional compositions should not be a problem. I assume you set the
aggregation kind to 'composite' for just the owning end?

Kenn

"Pradeep" <eclipseuser123@yahoo.com> wrote in message
news:f3njpp$jm2$1@build.eclipse.org...
> Hi,
>
> When I have bi-directional associations, if I update oneside otherside is
> automatically getting updated.
>
> Does it anyway differ if I one side of the relationship is composition.
>
> i.e
>
> A contains a list of Bs, and Each B has a reference to A.
>
>
> class A {
>
> // I set the association to composite aggregation.
> EList<B> bs;
> }
>
> class B {
> A a;
> }
>
> Now, I am forced to update both the objects. Otherwise it is resulting in
> NullPointerExeception.
>
> Thanks
> Pradeep
>
>
Re: update problem with Bidirectional composite aggregation [message #619672 is a reply to message #473081] Fri, 01 June 2007 16:49 Go to previous message
Pradeep is currently offline PradeepFriend
Messages: 54
Registered: July 2009
Member
I did exactly the way James suggested earlier. My question is how do I get
bidirectional navigation in case of composite aggregation.

Yes, I did set the aggregation kind to composite just for the owned end.

But changing the other end to composite is not helping either.

i.e.

If I say

a.getBs().add(b)

and call b.getA() it is returning null.

Thanks
Pradeep



Pradeep,

Bidirectional compositions should not be a problem. I assume you set the
aggregation kind to 'composite' for just the owning end?

Kenn


"James Bruck" <jbruck@ca.ibm.com> wrote in message
news:f3pcbe$t50$2@build.eclipse.org...
> Hi Pradeep,
>
> You can make your composition association navigable in one way by doing
> the
> following...
>
> Create a class call it "Class1".
> Create a class call it "Class2".
> Create an association call it "A".
> Create a property under Class1.
> Set the aggregation to composite.
> Set the association to "A".
> Set its type to Class2.
> Set multiplicity .
> Create a property under "A"
> Set its type to Class1.
> Set its association to "A"
> Set its aggregation to "none"
> For association "A"
> Set the Member ends to the two newly created properties.
>
>
> When you convert that to .ecore you should see..
> Class1 with EReference of type Class2.
> Class2.
>
> It sounds like that is what you want to do.
>
> Regards,
>
> - James.
>
>
> "Pradeep" <eclipseuser123@yahoo.com> wrote in message
> news:f3njpp$jm2$1@build.eclipse.org...
>> Hi,
>>
>> When I have bi-directional associations, if I update oneside otherside is
>> automatically getting updated.
>>
>> Does it anyway differ if I one side of the relationship is composition.
>>
>> i.e
>>
>> A contains a list of Bs, and Each B has a reference to A.
>>
>>
>> class A {
>>
>> // I set the association to composite aggregation.
>> EList<B> bs;
>> }
>>
>> class B {
>> A a;
>> }
>>
>> Now, I am forced to update both the objects. Otherwise it is resulting in
>> NullPointerExeception.
>>
>> Thanks
>> Pradeep
>>
>>
>
>
Re: update problem with Bidirectional composite aggregation [message #619674 is a reply to message #473084] Fri, 01 June 2007 19:02 Go to previous message
james bruck is currently offline james bruckFriend
Messages: 1724
Registered: July 2009
Senior Member
If you want a bidirectional composite association then you need to do
something a bit different...
( I thought you really wanted a "one way navigable" composite association ).

Try this ...


Create a class call it "Class1".
Create a class call it "Class2".
Create an association call it "A".
Create a property under Class1.
Set the aggregation to composite.
Set the association to "A".
Set its type to Class2.
Set multiplicity .
Create a property under Class2
Set its type to Class1.
Set its association to "A"
Set its aggregation to "none"
For association "A"
Set the Member ends to the two newly created properties.



James.


"Pradeep" <eclipseuser123@yahoo.com> wrote in message
news:f3pin7$4oi$1@build.eclipse.org...
>
> I did exactly the way James suggested earlier. My question is how do I get
> bidirectional navigation in case of composite aggregation.
>
> Yes, I did set the aggregation kind to composite just for the owned end.
>
> But changing the other end to composite is not helping either.
>
> i.e.
>
> If I say
>
> a.getBs().add(b)
>
> and call b.getA() it is returning null.
>
> Thanks
> Pradeep
>
>
>
> Pradeep,
>
> Bidirectional compositions should not be a problem. I assume you set the
> aggregation kind to 'composite' for just the owning end?
>
> Kenn
>
>
> "James Bruck" <jbruck@ca.ibm.com> wrote in message
> news:f3pcbe$t50$2@build.eclipse.org...
> > Hi Pradeep,
> >
> > You can make your composition association navigable in one way by doing
> > the
> > following...
> >
> > Create a class call it "Class1".
> > Create a class call it "Class2".
> > Create an association call it "A".
> > Create a property under Class1.
> > Set the aggregation to composite.
> > Set the association to "A".
> > Set its type to Class2.
> > Set multiplicity .
> > Create a property under "A"
> > Set its type to Class1.
> > Set its association to "A"
> > Set its aggregation to "none"
> > For association "A"
> > Set the Member ends to the two newly created properties.
> >
> >
> > When you convert that to .ecore you should see..
> > Class1 with EReference of type Class2.
> > Class2.
> >
> > It sounds like that is what you want to do.
> >
> > Regards,
> >
> > - James.
> >
> >
> > "Pradeep" <eclipseuser123@yahoo.com> wrote in message
> > news:f3njpp$jm2$1@build.eclipse.org...
> >> Hi,
> >>
> >> When I have bi-directional associations, if I update oneside otherside
is
> >> automatically getting updated.
> >>
> >> Does it anyway differ if I one side of the relationship is composition.
> >>
> >> i.e
> >>
> >> A contains a list of Bs, and Each B has a reference to A.
> >>
> >>
> >> class A {
> >>
> >> // I set the association to composite aggregation.
> >> EList<B> bs;
> >> }
> >>
> >> class B {
> >> A a;
> >> }
> >>
> >> Now, I am forced to update both the objects. Otherwise it is resulting
in
> >> NullPointerExeception.
> >>
> >> Thanks
> >> Pradeep
> >>
> >>
> >
> >
>
>
Previous Topic:Where did getAppliedVersion and applyProfile move to?
Next Topic:heavyweight extension in OMG specifications
Goto Forum:
  


Current Time: Thu Apr 18 11:12:07 GMT 2024

Powered by FUDForum. Page generated in 0.02415 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top