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 protected])
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/webobjects-dev/mastermind%40knuckleheads.net
>
> This email sent to [email protected]
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list ([email protected])
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com
This email sent to [email protected]