Page 1 of 1

New inverse relationship

Posted: Fri Aug 07, 2009 12:06 pm
by ConvertFromOldNGs
by NZWTA >> Tue, 12 Feb 2002 6:42:10 GMT

Hi

Ver 5.0.14 - A problem that must have an obvious answer (but I can't see it???), Ive just added a collection, type "TestBasicDataLotNoDict", to an the Root class, to be automatically updated by setting the "myRoot" reference of a given "TestBasicData" object (see below). The reorg didn't add existing objects to the collection (I can remember this being documented somewhere???)... how do I get the existing objects into the collection?

I tried iterating through all the objects re-setting the "myRoot" reference, but since it isn't really changing from its current setting the object wasn't in effect updated, so back to square one. What does work, but a bit messy, is not defining the inverse relationship, iterating through objects using .add collection method, then adding inverse. Two big reorgs! What's the simple answer?

Regards
Dave Mellow

-----------------------------------------------------------------


Name: allTestBasicDataByLotNo (71)
Class: Root
Type: TestBasicDataLotNoDict
Access: protected (0)
SubId: 58
non-virtual

Inverses:
myRoot of TestBasicData
Update Mode: Automatic
Relationship Type: peer-to-peer



Name: myRoot (148)
Class: TestBasicData
Type: Root
Access: protected (0)
non-virtual embedded

Inverses:
allTestBasicData of Root
allTestBasicDataByDateComplete of Root
allTestBasicDataByReference of Root
allTestBasicDataCustRef of Root
allTestBasicDataSale of Root
allTestBasicDataByLotNo of Root
Update Mode: Manual
Relationship Type: peer-to-peer

Re: New inverse relationship

Posted: Fri Aug 07, 2009 12:06 pm
by ConvertFromOldNGs
by dcooper@jade.co.nz >> Tue, 12 Feb 2002 6:48:06 GMT

Instead of just setting each myRoot reference to its current value (I'm assuming this is what you did), save the myRoot reference in a local var, set myRoot to null, then set it back from the local var.

The kernel optimises inverse maintenance for single-value references so that if the value is not being changed, no inverse maintenance is performed. By setting the reference to null and then setting it back, you'll force inverse maintenance to be performed.

Dean.

Re: New inverse relationship

Posted: Fri Aug 07, 2009 12:06 pm
by ConvertFromOldNGs
by NZWTA >> Tue, 12 Feb 2002 20:30:40 GMT

Thanks Dean.

Our system consistently uses protected properties with get... and set... methods to access them. After fluffing around for a while not getting anywhere I discovered that the TestBasicData.setMyRoot method was coded to do nothing if the myRoot was already non-null - once I changed line line of script to setPropertyValue("myRoot",null) your suggestion worked fine!