Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [teneo] bidirectional OneToOne containment association - container not set in child object
[teneo] bidirectional OneToOne containment association - container not set in child object [message #70386] Sat, 03 February 2007 18:46 Go to next message
Andre Pareis is currently offline Andre PareisFriend
Messages: 113
Registered: July 2009
Senior Member
Hi alltogether,

on CVS head version of teneo and previous versions:

I can successfully save and load a containment hierarchy with a one-to-one
association between a container and a child, and this hierarchy is displayed
correctly in the editor tree. However, if I invoke a method on the child which
navigates to the container, either via the named association or the eContainer()
I found that the container reference is null. Only the container has a reference
set to the child, but not vice-versa.

I tried to play around with the code here in HibernatePersistableEList:

// disabled for now as containers are persisted by hibernate anyway
if (false && isContainment()) {
final int featureID = getEStructuralFeature().getFeatureID();
for (int i = 0; i < objs.length; i++) {
if (objs[i] instanceof InternalEObject) {
EContainerRepairControl.setContainer(owner, (InternalEObject) objs[i],
getEStructuralFeature());
}
}
}

I've set the constant to "true" but it did not have any positive effect.

Any help? How or when do you expect hibernate to set both side of the association?

Thanks
Andre
Re: [teneo] bidirectional OneToOne containment association - container not set in child object [message #70464 is a reply to message #70386] Mon, 05 February 2007 19:26 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Andre,
Did you use the option: DISABLE_ECONTAINER_MAPPING? If set to true then no econtainer information is
stored in the table and the econtainer is not set when reading one-to-one.
The HibernatePersistableEList is only used to one-to-many and not for one-to-one relations.

gr. Martin

Andre Pareis wrote:
> Hi alltogether,
>
> on CVS head version of teneo and previous versions:
>
> I can successfully save and load a containment hierarchy with a
> one-to-one association between a container and a child, and this
> hierarchy is displayed correctly in the editor tree. However, if I
> invoke a method on the child which navigates to the container, either
> via the named association or the eContainer() I found that the container
> reference is null. Only the container has a reference set to the child,
> but not vice-versa.
>
> I tried to play around with the code here in HibernatePersistableEList:
>
> // disabled for now as containers are persisted by hibernate anyway
> if (false && isContainment()) {
> final int featureID = getEStructuralFeature().getFeatureID();
> for (int i = 0; i < objs.length; i++) {
> if (objs[i] instanceof InternalEObject) {
> EContainerRepairControl.setContainer(owner,
> (InternalEObject) objs[i], getEStructuralFeature());
> }
> }
> }
>
> I've set the constant to "true" but it did not have any positive effect.
>
> Any help? How or when do you expect hibernate to set both side of the
> association?
>
> Thanks
> Andre


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: [teneo] bidirectional OneToOne containment association - container not set in child object [message #70602 is a reply to message #70464] Tue, 06 February 2007 19:26 Go to previous messageGo to next message
Andre Pareis is currently offline Andre PareisFriend
Messages: 113
Registered: July 2009
Senior Member
Hi Martin,

no I don't set this. So I assumed it is all handled automatically. The result is
now that in one direction (from parent to child) the association is set, but not
in the other direction (from child to parent).

Is there something else I can do to achieve this but without enabling the
DISABLE_ECONTAINER_MAPPING option? Definitely I do not want to have these
container attributes in the DB.

Thanks,
Andre


Martin Taal wrote:
> Hi Andre,
> Did you use the option: DISABLE_ECONTAINER_MAPPING? If set to true then
> no econtainer information is
> stored in the table and the econtainer is not set when reading one-to-one.
> The HibernatePersistableEList is only used to one-to-many and not for
> one-to-one relations.
>
> gr. Martin
>
> Andre Pareis wrote:
>> Hi alltogether,
>>
>> on CVS head version of teneo and previous versions:
>>
>> I can successfully save and load a containment hierarchy with a
>> one-to-one association between a container and a child, and this
>> hierarchy is displayed correctly in the editor tree. However, if I
>> invoke a method on the child which navigates to the container, either
>> via the named association or the eContainer() I found that the
>> container reference is null. Only the container has a reference set to
>> the child, but not vice-versa.
>>
>> I tried to play around with the code here in HibernatePersistableEList:
>>
>> // disabled for now as containers are persisted by hibernate anyway
>> if (false && isContainment()) {
>> final int featureID = getEStructuralFeature().getFeatureID();
>> for (int i = 0; i < objs.length; i++) {
>> if (objs[i] instanceof InternalEObject) {
>> EContainerRepairControl.setContainer(owner,
>> (InternalEObject) objs[i], getEStructuralFeature());
>> }
>> }
>> }
>>
>> I've set the constant to "true" but it did not have any positive effect.
>>
>> Any help? How or when do you expect hibernate to set both side of the
>> association?
>>
>> Thanks
>> Andre
>
>
Re: [teneo] bidirectional OneToOne containment association - container not set in child object [message #70669 is a reply to message #70602] Tue, 06 February 2007 22:56 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Andre,
I am not sure, do you explicitly set DISABLE_ECONTAINER_MAPPING to true? If not set (it's default is
false) then the econtainer fields should be present in the db (unless you have overridden HbDataStore).
If the econtainer info is not set in the db then when the child is read (without its parent) then it
won't know of its parent (as it has not been defined in the db).
So the relation can only be managed correctly if the parent has also been read. Although I need to
make a change to accomplish this as the current approach is completely based on the econtainer being
present in the db.

Would it work if the parent needs to be read also (with a tree view this will be the case most of
the time)?

gr. Martin

Andre Pareis wrote:
> Hi Martin,
>
> no I don't set this. So I assumed it is all handled automatically. The
> result is now that in one direction (from parent to child) the
> association is set, but not in the other direction (from child to parent).
>
> Is there something else I can do to achieve this but without enabling
> the DISABLE_ECONTAINER_MAPPING option? Definitely I do not want to have
> these container attributes in the DB.
>
> Thanks,
> Andre
>
>
> Martin Taal wrote:
>> Hi Andre,
>> Did you use the option: DISABLE_ECONTAINER_MAPPING? If set to true
>> then no econtainer information is
>> stored in the table and the econtainer is not set when reading
>> one-to-one.
>> The HibernatePersistableEList is only used to one-to-many and not for
>> one-to-one relations.
>>
>> gr. Martin
>>
>> Andre Pareis wrote:
>>> Hi alltogether,
>>>
>>> on CVS head version of teneo and previous versions:
>>>
>>> I can successfully save and load a containment hierarchy with a
>>> one-to-one association between a container and a child, and this
>>> hierarchy is displayed correctly in the editor tree. However, if I
>>> invoke a method on the child which navigates to the container, either
>>> via the named association or the eContainer() I found that the
>>> container reference is null. Only the container has a reference set
>>> to the child, but not vice-versa.
>>>
>>> I tried to play around with the code here in HibernatePersistableEList:
>>>
>>> // disabled for now as containers are persisted by hibernate anyway
>>> if (false && isContainment()) {
>>> final int featureID = getEStructuralFeature().getFeatureID();
>>> for (int i = 0; i < objs.length; i++) {
>>> if (objs[i] instanceof InternalEObject) {
>>> EContainerRepairControl.setContainer(owner,
>>> (InternalEObject) objs[i], getEStructuralFeature());
>>> }
>>> }
>>> }
>>>
>>> I've set the constant to "true" but it did not have any positive effect.
>>>
>>> Any help? How or when do you expect hibernate to set both side of the
>>> association?
>>>
>>> Thanks
>>> Andre
>>
>>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: [teneo] bidirectional OneToOne containment association - container not set in child object [message #602153 is a reply to message #70386] Mon, 05 February 2007 19:26 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Andre,
Did you use the option: DISABLE_ECONTAINER_MAPPING? If set to true then no econtainer information is
stored in the table and the econtainer is not set when reading one-to-one.
The HibernatePersistableEList is only used to one-to-many and not for one-to-one relations.

gr. Martin

Andre Pareis wrote:
> Hi alltogether,
>
> on CVS head version of teneo and previous versions:
>
> I can successfully save and load a containment hierarchy with a
> one-to-one association between a container and a child, and this
> hierarchy is displayed correctly in the editor tree. However, if I
> invoke a method on the child which navigates to the container, either
> via the named association or the eContainer() I found that the container
> reference is null. Only the container has a reference set to the child,
> but not vice-versa.
>
> I tried to play around with the code here in HibernatePersistableEList:
>
> // disabled for now as containers are persisted by hibernate anyway
> if (false && isContainment()) {
> final int featureID = getEStructuralFeature().getFeatureID();
> for (int i = 0; i < objs.length; i++) {
> if (objs[i] instanceof InternalEObject) {
> EContainerRepairControl.setContainer(owner,
> (InternalEObject) objs[i], getEStructuralFeature());
> }
> }
> }
>
> I've set the constant to "true" but it did not have any positive effect.
>
> Any help? How or when do you expect hibernate to set both side of the
> association?
>
> Thanks
> Andre


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: [teneo] bidirectional OneToOne containment association - container not set in child object [message #602233 is a reply to message #70464] Tue, 06 February 2007 19:26 Go to previous message
Andre Pareis is currently offline Andre PareisFriend
Messages: 113
Registered: July 2009
Senior Member
Hi Martin,

no I don't set this. So I assumed it is all handled automatically. The result is
now that in one direction (from parent to child) the association is set, but not
in the other direction (from child to parent).

Is there something else I can do to achieve this but without enabling the
DISABLE_ECONTAINER_MAPPING option? Definitely I do not want to have these
container attributes in the DB.

Thanks,
Andre


Martin Taal wrote:
> Hi Andre,
> Did you use the option: DISABLE_ECONTAINER_MAPPING? If set to true then
> no econtainer information is
> stored in the table and the econtainer is not set when reading one-to-one.
> The HibernatePersistableEList is only used to one-to-many and not for
> one-to-one relations.
>
> gr. Martin
>
> Andre Pareis wrote:
>> Hi alltogether,
>>
>> on CVS head version of teneo and previous versions:
>>
>> I can successfully save and load a containment hierarchy with a
>> one-to-one association between a container and a child, and this
>> hierarchy is displayed correctly in the editor tree. However, if I
>> invoke a method on the child which navigates to the container, either
>> via the named association or the eContainer() I found that the
>> container reference is null. Only the container has a reference set to
>> the child, but not vice-versa.
>>
>> I tried to play around with the code here in HibernatePersistableEList:
>>
>> // disabled for now as containers are persisted by hibernate anyway
>> if (false && isContainment()) {
>> final int featureID = getEStructuralFeature().getFeatureID();
>> for (int i = 0; i < objs.length; i++) {
>> if (objs[i] instanceof InternalEObject) {
>> EContainerRepairControl.setContainer(owner,
>> (InternalEObject) objs[i], getEStructuralFeature());
>> }
>> }
>> }
>>
>> I've set the constant to "true" but it did not have any positive effect.
>>
>> Any help? How or when do you expect hibernate to set both side of the
>> association?
>>
>> Thanks
>> Andre
>
>
Re: [teneo] bidirectional OneToOne containment association - container not set in child object [message #602255 is a reply to message #70602] Tue, 06 February 2007 22:56 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Andre,
I am not sure, do you explicitly set DISABLE_ECONTAINER_MAPPING to true? If not set (it's default is
false) then the econtainer fields should be present in the db (unless you have overridden HbDataStore).
If the econtainer info is not set in the db then when the child is read (without its parent) then it
won't know of its parent (as it has not been defined in the db).
So the relation can only be managed correctly if the parent has also been read. Although I need to
make a change to accomplish this as the current approach is completely based on the econtainer being
present in the db.

Would it work if the parent needs to be read also (with a tree view this will be the case most of
the time)?

gr. Martin

Andre Pareis wrote:
> Hi Martin,
>
> no I don't set this. So I assumed it is all handled automatically. The
> result is now that in one direction (from parent to child) the
> association is set, but not in the other direction (from child to parent).
>
> Is there something else I can do to achieve this but without enabling
> the DISABLE_ECONTAINER_MAPPING option? Definitely I do not want to have
> these container attributes in the DB.
>
> Thanks,
> Andre
>
>
> Martin Taal wrote:
>> Hi Andre,
>> Did you use the option: DISABLE_ECONTAINER_MAPPING? If set to true
>> then no econtainer information is
>> stored in the table and the econtainer is not set when reading
>> one-to-one.
>> The HibernatePersistableEList is only used to one-to-many and not for
>> one-to-one relations.
>>
>> gr. Martin
>>
>> Andre Pareis wrote:
>>> Hi alltogether,
>>>
>>> on CVS head version of teneo and previous versions:
>>>
>>> I can successfully save and load a containment hierarchy with a
>>> one-to-one association between a container and a child, and this
>>> hierarchy is displayed correctly in the editor tree. However, if I
>>> invoke a method on the child which navigates to the container, either
>>> via the named association or the eContainer() I found that the
>>> container reference is null. Only the container has a reference set
>>> to the child, but not vice-versa.
>>>
>>> I tried to play around with the code here in HibernatePersistableEList:
>>>
>>> // disabled for now as containers are persisted by hibernate anyway
>>> if (false && isContainment()) {
>>> final int featureID = getEStructuralFeature().getFeatureID();
>>> for (int i = 0; i < objs.length; i++) {
>>> if (objs[i] instanceof InternalEObject) {
>>> EContainerRepairControl.setContainer(owner,
>>> (InternalEObject) objs[i], getEStructuralFeature());
>>> }
>>> }
>>> }
>>>
>>> I've set the constant to "true" but it did not have any positive effect.
>>>
>>> Any help? How or when do you expect hibernate to set both side of the
>>> association?
>>>
>>> Thanks
>>> Andre
>>
>>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Previous Topic:[Teneo] How to set 'cascade="none"' on many-to-one reference in Hibernate
Next Topic:[Teneo] How to set 'cascade="none"' on many-to-one reference in Hibernate
Goto Forum:
  


Current Time: Thu Feb 25 23:28:00 GMT 2021

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

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

Back to the top