update problem with Bidirectional composite aggregation [message #473071] |
Thu, 31 May 2007 18:55  |
Eclipse User |
|
|
|
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 15:02  |
Eclipse User |
|
|
|
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 11:01  |
Eclipse User |
|
|
|
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 11:39  |
Eclipse User |
|
|
|
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 12:49  |
Eclipse User |
|
|
|
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 15:02  |
Eclipse User |
|
|
|
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
> >>
> >>
> >
> >
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.25250 seconds