Re: ERXEOControlUtilities.objectCountForToManyRelationship for new objects fails?
Re: ERXEOControlUtilities.objectCountForToManyRelationship for new objects fails?
- Subject: Re: ERXEOControlUtilities.objectCountForToManyRelationship for new objects fails?
- From: Chuck Hill <email@hidden>
- Date: Wed, 13 Apr 2016 17:18:40 +0000
- Thread-topic: ERXEOControlUtilities.objectCountForToManyRelationship for new objects fails?
I suspect your code. If it is newly inserted and saved (and even unsaved I think) they should be an empty array, not null.
On 2016-04-13, 10:12 AM, "webobjects-dev-bounces+chill=email@hidden on behalf of OC" <webobjects-dev-bounces+chill=email@hidden on behalf of email@hidden> wrote:
>Hi there,
>
>with ERXEOControlUtilities.objectCountForToManyRelationship I have bumped into a weird problem — with newly created EOs it fails, yelling that “... is not a toMany relationship! Expected an NSArray, but got null” (exact copy below).
>
>Now, perhaps I do something wrong, but it seems to me it is perfectly normal in EOF that all to-manys of a newly created EO are null? At the very least, whenever I checked, they were.
>
>So far, the only fix I have found is to refault the newly created object immediately, which helps (fetch replaces those nulls by empty arrays), but it is pretty ugly:
>
>===
> DBDataBlock bc=... create new EO and insert it into an EC ...
> ... set it up ...
> if (!ec.saveChanges()) return ERROR...
> bc.editingContext.refaultObject(bc) // <==== this helps. Without this line, to-manys are nulls now
>===
>
>Is there any better solution?
>
>And what am I overlooking? To me, the check for null in objectCountForToManyRelationship looks like a bug.
>
>Thanks a lot,
>OC
>
>===
>18:53:43.124 WARN <er.extensions.appserver.ERXComponentRequestHandler>: Exception occurred while handling request:
>java.lang.IllegalArgumentException: The attribute named 'actions' in the entity named 'DBDataBlock' is not a toMany relationship! Expected an NSArray, but got null. //log:NSLog [WorkerThread0]
>[2016-4-13 18:53:43 CEST] <WorkerThread0> java.lang.IllegalArgumentException: The attribute named 'actions' in the entity named 'DBDataBlock' is not a toMany relationship! Expected an NSArray, but got null.
> at er.extensions.eof.ERXEOControlUtilities.objectCountForToManyRelationship(ERXEOControlUtilities.java:802)
>...
>===
> _______________________________________________
>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