• 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: AddObjectToBothSidesOfRelationshipWithkey
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: AddObjectToBothSidesOfRelationshipWithkey


  • Subject: Re: AddObjectToBothSidesOfRelationshipWithkey
  • From: Chuck Hill <email@hidden>
  • Date: Thu, 19 Apr 2007 10:03:59 -0700


On Apr 19, 2007, at 7:42 AM, Frank Stock wrote:

Ken,

I have a many to many relation.

A<->>B<<->C

Primary keys are A.pk,B.pk,C.pk


The select statements are (after the 2 addObjectToBothSidesOfRelationshipWithKey)



select t0..... from B where A.pk= xxxx; select t0.... from B where C.pk = xxxx;

This doesn't make sense to me why these select statements are performed.

Object graph consistency. You asked it to add to both sides of the relationship. So it needs to read in the data and populate the relationships on both sides before it can update them.



Chuck


Op 19-apr-07, om 16:05 heeft Ken Anderson het volgende geschreven:

Frank,

Are you saying that you end up with more records in the relationship than you'd expect, or that the query is selecting a larger group than you'd expect? Is it possible the destination entity is set to 'Cache in Memory' on the inspector? If your to- many relationship has a qualifier and that's not being applied, that would be my guess.

Please give us more details on the relationships...

Ken

On Apr 19, 2007, at 9:57 AM, Frank Stock wrote:

Ken,


what I don't understand is why all the relation-rows are fetched, not just the selection thats needed?


Frank
Op 19-apr-07, om 14:37 heeft Ken Anderson het volgende geschreven:

Frank,

There must be a large number of objects in the relationship you're adding to. In that case, you might want to just add it to the other side. Is it a relationship that you use often? If so, you might want to consider changing how it works so that there's not such a large group of objects being returned.

In other words, if you have a to many with an opposite to-one:

A <-->> B

If you set B's to-one relationship to A (not using the both sides method), you won't trigger the to-many fault. Of course, if the to-many fault has already been triggered, you're going to have an inaccurate object graph. A hokey solution might be to test whether to to-many relationship from A to B is a fault or a real array, and then add in that direction if necessary.

Bottom line - I would change my relationships. Do you absolutely need this to-many relationship? Could it be handled with a fetch instead for a once in a while situation? A common misconception that people have is that they should model both directions of every relationship. Only model what you need...

Ken

On Apr 19, 2007, at 7:41 AM, Frank Stock wrote:

HI,

I did test it with addTo<relationsShipName> and that just gives me the same result!

Thanks,
Frank Stock
Op 19-apr-07, om 13:30 heeft Shravan Kumar.M het volgende geschreven:


Hello Frank,

When there is a one-to-many or many-to-many it is advised not use addObjectToBothSidesOfRelationshipWithKey instead use the individual addTo<relationShipName>() methods. When we use addObjectToBothSidesOfRelationshipWithKey , it tries to fault the objects in the relationship and that is what you see "Select statements". Better go with addTo<relationShipName>() methods in such cases.

Thanks & Rgds,
Shravan Kumar.M

"Let us learn from the past to profit by the present,and from the present to live better in the future."
--William WordsWorth
---------------------------------------------------------------



On 19-Apr-07, at 4:50 PM, webobjects-dev- email@hidden wrote:




From: Frank Stock <email@hidden>
Date: 19 April 2007 4:50:08 PM GMT+05:30
To: email@hidden
Subject: AddObjectToBothSidesOfRelationshipWithkey


Hi,


When I do this:


bpObject = new BlockProperty();
ec.insertObject(bpObject);
bpObject.setValue(value);
bpObject.addObjectToBothSidesOfRelationshipWithKey (bObject,"block");
bpObject.addObjectToBothSidesOfRelationshipWithKey (pObject,"property");


This will take 90 seconds to complete (will all the rest of the code)


I can see in the debugger that every time I do a AddObjectToBothSidesOfRelationshipWithkey WO will perform a select-statement,
the relations have a lot of records (>2000). I have to to that a lot of time and all I need is just to make a relation between the objects.
Why is WO performing a select every time and can I avoid that?
If I just do :
bpObject = new BlockProperty();
ec.insertObject(bpObject);
bpObject.setValue(value);
bObject.addToBlockProperty(bpObject);
pObject.addToBlockProperty(bpObject);

This will take 5 seconds to complete (will all the rest of the code)




Thanks,
Frank Stock
_______________________________________________
Webobjects-dev mailing list
email@hidden
http://lists.apple.com/mailman/listinfo/webobjects-dev


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


This email sent to email@hidden




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


This email sent to email@hidden

--

Practical WebObjects - for developers who want to increase their overall knowledge of WebObjects or who are trying to solve specific problems.
http://www.global-village.net/products/practical_webobjects






_______________________________________________
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


References: 
 >Re: AddObjectToBothSidesOfRelationshipWithkey (From: "Shravan Kumar.M" <email@hidden>)
 >Re: AddObjectToBothSidesOfRelationshipWithkey (From: Frank Stock <email@hidden>)
 >Re: AddObjectToBothSidesOfRelationshipWithkey (From: Ken Anderson <email@hidden>)
 >Re: AddObjectToBothSidesOfRelationshipWithkey (From: Frank Stock <email@hidden>)
 >Re: AddObjectToBothSidesOfRelationshipWithkey (From: Ken Anderson <email@hidden>)
 >Re: AddObjectToBothSidesOfRelationshipWithkey (From: Frank Stock <email@hidden>)

  • Prev by Date: Re: Fetch objects: Error in MYSQL or WO
  • Next by Date: Re: Converting from Session to DA
  • Previous by thread: Re: AddObjectToBothSidesOfRelationshipWithkey
  • Next by thread: Re: AddObjectToBothSidesOfRelationshipWithkey
  • Index(es):
    • Date
    • Thread