• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Updating Nested To-Many Relationship *NOT SOLVED*
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Updating Nested To-Many Relationship *NOT SOLVED*


  • Subject: Re: Updating Nested To-Many Relationship *NOT SOLVED*
  • From: David Avendasora <email@hidden>
  • Date: Wed, 11 Apr 2007 08:08:49 -0500
  • Resent-date: Wed, 11 Apr 2007 08:30:14 -0500
  • Resent-from: David Avendasora <email@hidden>
  • Resent-message-id: <email@hidden>
  • Resent-to: WebObjects Dev Apple <email@hidden>

(truncated old messages to get past filter)

On Apr 11, 2007, at 6:36 AM, Ken Anderson wrote:

David,

Are you sure you're looking at the same RSComponent when you find all the relationships null?  To me, that is a clear case of RSComponent being the target of a mandatory to-one relationship.  Under certain circumstances, EOF will create an empty EO that's the target of that mandatory to-one.

Ken


I'm sure it's not a new, empty instance of the rsComponent..

#1) the rsComponents() relationship is not maditory in the EOModel, and it is to-many from RoutingStep (RoutingStep<-->>rsComponent).
#2) I have logging (thanks to EOGenerator) on all my setters, and it shows what the previous value was and what the new value is. It is taking an object with values, and nullifying them.

Here's an example from the Run Log. See comments within: 

Here it sets the routingStep relationship properly (see bottom of email for the setRoutingStepRelationship() code).

2007-04-11 07:45:27,282 DEBUG com.bestmaid.bakeryManagement.routing._BillOfMaterialComponent:setRoutingStepRelationship - updating routingStep from {values = {routingStepSequence = 4; instructions = "Fast Blend Oats 10-15-SECONDS"; workCenter = "<com.bestmaid.bakeryManagement.routing.WorkCenter 283922 _EOIntegralKeyGlobalID[WorkCenter (java.lang.Long)1]>"; routing = "<com.bestmaid.bakeryManagement.routing.BillOfMaterial 50262b _EOIntegralKeyGlobalID[BillOfMaterial (java.lang.Long)1758]>"; billOfMaterialComponents = ("<com.bestmaid.bakeryManagement.routing.BillOfMaterialComponent 583f4c _EOIntegralKeyGlobalID[BillOfMaterialComponent (java.lang.Long)8495]>"); routingStepName = "Fast Blend Oats"; toolConfigurations = "<com.webobjects.eocontrol._EOCheapCopyMutableArray 587427 (<EOAccessArrayFaultHandler toolConfigurations _EOIntegralKeyGlobalID[RoutingStep (java.lang.Long)7164]>)>"; }; this = "<com.bestmaid.bakeryManagement.routing.RoutingStep 8475ef _EOIntegralKeyGlobalID[RoutingStep (java.lang.Long)7164]>"; } to {values = {routingStepSequence = 5; instructions = "Test"; workCenter = "<com.bestmaid.bakeryManagement.routing.WorkCenter 283922 _EOIntegralKeyGlobalID[WorkCenter (java.lang.Long)1]>"; routing = "<com.bestmaid.bakeryManagement.routing.BillOfMaterial 50262b _EOIntegralKeyGlobalID[BillOfMaterial (java.lang.Long)1758]>"; billOfMaterialComponents = (); routingStepName = "Test"; toolConfigurations = "<com.webobjects.eocontrol._EOCheapCopyMutableArray 31eb31 (<EOAccessArrayFaultHandler toolConfigurations _EOIntegralKeyGlobalID[RoutingStep (java.lang.Long)7167]>)>"; }; this = "<com.bestmaid.bakeryManagement.routing.RoutingStep a614a4 _EOIntegralKeyGlobalID[RoutingStep (java.lang.Long)7167]>"; }

Immediately followed by other misc updates:

2007-04-11 07:45:27,287 DEBUG com.bestmaid.bakeryManagement.routing._BillOfMaterialComponent:setLineNumber - updating lineNumber from 17 to 17
2007-04-11 07:45:27,354 DEBUG com.bestmaid.bakeryManagement.routing._BillOfMaterialComponent:setScrapPercent - updating scrapPercent from 0.000000 to 0.0000

Here it begins setting all attributes of the same rsComponent (aka BillOfMaterialComponent) to null! you can see by the time stamp that it is doing it immediately after the proper update. Also, I can tell by the attributes (part.partDescription, etc) that it is, in fact, the rsComponent that I requested be updated that is now being nullified.

2007-04-11 07:45:27,356 DEBUG com.bestmaid.bakeryManagement.routing._BillOfMaterialComponent:setRoutingStepRelationship - updating routingStep from {values = {routingStepSequence = 5; instructions = "Test"; workCenter = "<com.bestmaid.bakeryManagement.routing.WorkCenter 283922 _EOIntegralKeyGlobalID[WorkCenter (java.lang.Long)1]>"; routing = "<com.bestmaid.bakeryManagement.routing.BillOfMaterial 50262b _EOIntegralKeyGlobalID[BillOfMaterial (java.lang.Long)1758]>"; billOfMaterialComponents = ("<com.bestmaid.bakeryManagement.routing.BillOfMaterialComponent 583f4c _EOIntegralKeyGlobalID[BillOfMaterialComponent (java.lang.Long)8495]>"); routingStepName = "Test"; toolConfigurations = "<com.webobjects.eocontrol._EOCheapCopyMutableArray 31eb31 (<EOAccessArrayFaultHandler toolConfigurations _EOIntegralKeyGlobalID[RoutingStep (java.lang.Long)7167]>)>"; }; this = "<com.bestmaid.bakeryManagement.routing.RoutingStep a614a4 _EOIntegralKeyGlobalID[RoutingStep (java.lang.Long)7167]>"; } to null

[2007-04-11 07:45:27 COT] <WorkerThread2> Validation failed on an object [null] with keypath = aRequestedBillOfMaterialBillOfMaterialComponent.lineNumber and exception: The lineNumber property of BillOfMaterialComponent is not allowed to be null.

2007-04-11 07:45:27,371 DEBUG com.bestmaid.bakeryManagement.routing._BillOfMaterialComponent:setPartRelationship - updating part from {values = {rawType = "<com.bestmaid.bakeryManagement.part.RawType 54f497 (com.webobjects.eoaccess.EOAccessFaultHandler _EOIntegralKeyGlobalID[RawType (java.lang.Long)7])>"; unitOfMeasure = "<com.bestmaid.bakeryManagement.utility.UnitOfMeasure fed367 _EOIntegralKeyGlobalID[UnitOfMeasure (java.lang.Long)1]>"; lotCodes = "<com.webobjects.eocontrol._EOCheapCopyMutableArray b2b9ec (<EOAccessArrayFaultHandler lotCodes _EOIntegralKeyGlobalID[Raw (java.lang.Long)424]>)>"; componentOfBillsOfMaterial = "<com.webobjects.eocontrol._EOCheapCopyMutableArray c04c06 (<EOAccessArrayFaultHandler componentOfBillsOfMaterial _EOIntegralKeyGlobalID[Raw (java.lang.Long)424]>)>"; statementBlocks = "<com.webobjects.eocontrol._EOCheapCopyMutableArray f4c346 (<EOAccessArrayFaultHandler statementBlocks _EOIntegralKeyGlobalID[Raw (java.lang.Long)424]>)>"; partDescription = "Oats, Quick , Oats, Quick"; nutritionBlocks = "<com.webobjects.eocontrol._EOCheapCopyMutableArray cc6cb4 (<EOAccessArrayFaultHandler nutritionBlocks _EOIntegralKeyGlobalID[Raw (java.lang.Long)424]>)>"; partNumber = "02070000000041"; partType = "<com.bestmaid.bakeryManagement.part.PartType 860b1d (com.webobjects.eoaccess.EOAccessFaultHandler _EOIntegralKeyGlobalID[PartType (java.lang.Long)2])>"; partName = "Oats, Quick "; workCentersUsedIn = "<com.webobjects.eocontrol._EOCheapCopyMutableArray 43d287 (<EOAccessArrayFaultHandler workCentersUsedIn _EOIntegralKeyGlobalID[Raw (java.lang.Long)424]>)>"; }; this = "<com.bestmaid.bakeryManagement.part.Raw c6948c _EOIntegralKeyGlobalID[Raw (java.lang.Long)424]>"; } to null

[2007-04-11 07:45:27 COT] <WorkerThread2> Validation failed on an object [null] with keypath = aRequestedBillOfMaterialBillOfMaterialComponent.scrapFixed and exception: The scrapFixed property of BillOfMaterialComponent is not allowed to be null.

2007-04-11 07:45:27,404 DEBUG com.bestmaid.bakeryManagement.routing._BillOfMaterialComponent:setUnitOfMeasureRelationship - updating unitOfMeasure from {values = {uomAbbreviation = "lb"; uomNamePlural = "Pounds"; uomAbbreviationPlural = "lbs"; baseUnitOfMeasureConversions = "<com.webobjects.eocontrol._EOCheapCopyMutableArray 4f5403 (<EOAccessArrayFaultHandler baseUnitOfMeasureConversions _EOIntegralKeyGlobalID[UnitOfMeasure (java.lang.Long)1]>)>"; convertedUnitOfMeasureConversions = "<com.webobjects.eocontrol._EOCheapCopyMutableArray fb541d (<EOAccessArrayFaultHandler convertedUnitOfMeasureConversions _EOIntegralKeyGlobalID[UnitOfMeasure (java.lang.Long)1]>)>"; unitOfMeasureType = "<com.bestmaid.bakeryManagement.utility.UnitiOfMeasureType 1b7e37 (com.webobjects.eoacc[2007-04-11 07:45:27 COT] <WorkerThread2> Validation failed on an object [null] with keypath = aRequestedBillOfMaterialBillOfMaterialComponent.partQuantity and exception: The partQuantity property of BillOfMaterialComponent is not allowed to be null.

ess.EOAccessFaultHandler _EOIntegralKeyGlobalID[UnitOfMeasureType (java.lang.Long)1])>"; uomName = "Pound"; }; this = "<com.bestmaid.bakeryManagement.utility.UnitOfMeasure fed367 _EOIntegralKeyGlobalID[UnitOfMeasure (java.lang.Long)1]>"; } to null

[2007-04-11 07:45:27 COT] <WorkerThread2> Validation failed on an object [null] with keypath = aRequestedBillOfMaterialBillOfMaterialComponent.scrapPercent and exception: The scrapPercent property of BillOfMaterialComponent is not allowed to be null.

Here is the code for all my routingStep related getters and setters on the rsComponent class:

    public com.bestmaid.bakeryManagement.routing.RoutingStep routingStep() {
        return (com.bestmaid.bakeryManagement.routing.RoutingStep)storedValueForKey("routingStep");
    }

public com.bestmaid.bakeryManagement.routing.RoutingStep routingStepRelationship() {
        return routingStep();
    }

    public void setRoutingStepRelationship(com.bestmaid.bakeryManagement.routing.RoutingStep aValue) {
        if( log.isDebugEnabled() ) log.debug( "updating routingStep from "+routingStep()+" to "+aValue );
        if( aValue == null ) {
            com.bestmaid.bakeryManagement.routing.RoutingStep object = routingStep();
            if( object != null )
                removeObjectFromBothSidesOfRelationshipWithKey( object, "routingStep" );
        } else
            addObjectToBothSidesOfRelationshipWithKey( aValue, "routingStep" );
    }




On Apr 10, 2007, at 11:42 PM, David Avendasora wrote:

Okay, I spoke too soon.

It works to change SOME relationships, but not others. Here's what it does:

For example, if I change the relationship of a RSComponent from RoutingStep 4 to RoutingStep 3, it works as expected, simply changing both sides of the RoutingStep<-->>RSComponent relationship. BUT, if I then change the same RSComponent relationship back from RoutingStep 3 to RoutingStep 4, it also updates the relationship as expected, and then it continues on to set all the attributes and relationships of the RSComponent to null!

What is causing it to do this extra step of nullifying everything?!

I have also seen it "hijack" the values of an existing RSComponent in the target RoutingStep, then nullify all attributes of the RSComponent that it hijacked. This effectively makes it look like the RSComponent that I was moving from one RoutingStep to another disappears, but in fact it's there, just having been updated to look exactly like an existing RSComponent.

Very strange.
 
Dave

On Apr 10, 2007, at 1:29 PM, David Avendasora wrote:

Thanks Ken!

Once I read your message it seems SO obvious. I had to modify my EOGenerator template to add the new getter method, but once I did that and changed the binding, it works perfectly!

Dave


On Apr 10, 2007, at 1:08 PM, Ken Anderson wrote:

David,

Since you're changing a relationship and you want it to be reflected in the model immediately, you'll have to handle the action yourself and update the model using addObjectToBothSidesOfRelationshipWityKey or removeObjectFromBothSidesOfRelationshipWithKey.  If you're generating your classes with EOGenerator, you probably have methods that do this for you already.

The issue is, the pop up button just changes the value with key value coding, without affecting the opposite side of the relationship.

What I usually do in these circumstances is add 2 new methods to the EO - to replace the KVC normally used.  Something like:

- (RoutingStep) routingStepRelationship {
return this.routingStep();
}

- (void) setRoutingStepRelationship:(RoutingStep) step {
this.addObjectToBothSidesOfRelationshipWithKey(step, "routingStep");
}

Again, these can be auto-generated for you by EOGenerator.  If you then change the 'selection' binding of the pop-up from 'routingStep' to 'routingStepRelationship', KVC will call your set method, which will directly manipulate the object graph.

Ken

On Apr 10, 2007, at 1:35 PM, David Avendasora wrote:

I'm going to try to clarify  this a bit:

Here's the structure of my Form, the important part is in bold:

<WOForm>
aRouting
<WOTextField value=aRouting.routingDescription> 
<WOPopUpButton selected=aRouting.part>
<WORepetition list=aRouting.routingSteps item=aRoutingStep>
<WOTextField value=aRoutingStep.stepNumber>
<WOTextField value=aRoutingStep.stepName>
<WOTextArea value=aRoutingStep.instructions>
<WORepetition list=aRoutingStep.rsComponents item=aRSComponent>
<WOPopUpButton selected=aRSComponent.routingStep>
<WOTextField value=aRSComponent.lineNumber>
<WOPopUpButton selected=aRSComponent.part>
<WOTextField value=aRSComponent.quantity>
</WORepetition>
</WORepitition>
<WOSubmitButton/>
</WOForm>


Here's the code for the action of the WOSubmitButton:

    public WOComponent applyChangesToRouting() {
        return context().page();
    }

The critical portion is the relationship of RoutingStep<-->>RSComponent

When I select a different RoutingStep for a RSComponent using the WOPopUpButton and click the WOSubmitButton, it does update, but when the page comes back, the aRSComponent that I changed shows that it is now related to the new RoutingStep, but it is actually physically drawn on the page as still being in the original RoutingStep.

If I save the changes to the DB, and dump the session and re-enter the app, the RSComponent will be in the right location. So it seems to me that everything is actually being updated correctly, BUT the data being used to draw the page immediately after the update is _partially_ old. The original routingStep.rcComponents() array still has the old RCComponent in it and the new routingStep.rcComponents() array does not yet have the RCComponent in it that it should. BUT the rcComponent.routingStep() relationship DOES have the correct RoutingStep in it.

If I don't save it to the database and then come back in with a new session, then I only see half of the updated relationship.

How do I get the RoutingStep.rsComponents() relationship updates to show up?

Dave



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: Re: Updating Nested To-Many Relationship *NOT SOLVED*
  • Next by Date: Object Store
  • Previous by thread: Re: Instance number
  • Next by thread: Object Store
  • Index(es):
    • Date
    • Thread