• 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: Question about "To Many" relationships hooks in ERRest
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Question about "To Many" relationships hooks in ERRest


  • Subject: Re: Question about "To Many" relationships hooks in ERRest
  • From: Pascal Robert <email@hidden>
  • Date: Mon, 18 Jun 2012 20:47:48 -0400

I think it was a problem in the past, but right now with my one-line fix, it works fine when I create or update a blog entry, and if I set setAnonymousUpdateEnabled(true) on the categories, it creates the category as expected.

I'm going to commit it to the integration branch, if someone find a test case that my fix breaks, please say so.

> It was my understanding that many-to-many relationships had to be handled "manually" due to them not being processed correctly by the framework.
>
> -G
>
>
> On Jun 18, 2012, at 7:52 AM, Pascal Robert wrote:
>
>> I'm working on my WOWODC slides, and I'm doing something that I didn't do for many months: updating a 1:N (in fact, it's a N:N with a flatten relationship). So I have a blog entry which can have multiple categories, and I was doing an update to a blog post to add some categories, with:
>>
>> PUT /cgi-bin/WebObjects/WOWODCBlog.woa/ra/blogEntries/2.json HTTP/1.1
>>
>> { "id":2,"type":"BlogEntry", categories: [ {id : 1}, {id : 2} ] }
>>
>> Problem is: the categories were not linked to the blog post. Worse, if I make the link between a category and the blog entry with a "manual" EOF call, and after I try the same PUT call, it was emptying the relationship! So after debugging, I found that the problem was here:
>>
>> ERXRestRequestNode.java.updateObjectWithFilter
>>
>> I was getting into:
>>
>> 	if (toManyNode.children().count() == 0 && ERXRestUtils.isPrimitive(toManyNode.value())) {
>> 		if (lockedRelationship) {
>> 			childObj = null;
>> 		} else {
>> 			childObj = toManyNode.value();
>> 		}
>> 	}
>>
>> toManyNode.id was ok (returns the id I'm passing in), but value() is empty, so I was not reaching the logic below in the method that is adding the objects into the relationship. I fixed it by removed the call to 'toManyNode.value()' and adding :
>>
>> 	childObj = IERXRestDelegate.Factory.delegateForClassDescription(destinationClassDescription).objectOfEntityWithID(destinationClassDescription, id, context);
>>
>> Since then, works perfectly. But since that code was added last year (in commit 35a78ceea4f1c1cb713884d3f02b3f8d048b452c), I'm wondering is my fix is ok or it's me who do something wrong.
>>
>>
>> _______________________________________________
>> 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
>


 _______________________________________________
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: 
 >Question about "To Many" relationships hooks in ERRest (From: Pascal Robert <email@hidden>)
 >Re: Question about "To Many" relationships hooks in ERRest (From: George Domurot <email@hidden>)

  • Prev by Date: Re: Different Database Connection per session for the same model
  • Next by Date: Re: Different Database Connection per session for the same model
  • Previous by thread: Re: Question about "To Many" relationships hooks in ERRest
  • Next by thread: Different Database Connection per session for the same model
  • Index(es):
    • Date
    • Thread