• 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
ERXCopyable's Nullify in modelCopyRelationship()
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

ERXCopyable's Nullify in modelCopyRelationship()


  • Subject: ERXCopyable's Nullify in modelCopyRelationship()
  • From: Ricardo Parada <email@hidden>
  • Date: Wed, 07 Jan 2015 12:54:15 -0500


Hi David A., Chuck or anybody knowledgable about ERXCopyable,

Since I started using Wonder I noticed that when an EO is created and inserted into the editing context the to-many relationships have an empty array.  I really like this because it eliminated a lot of null checking logic before accessing to many relationships, I.e. I can do myToMany().count() without fear that I will get a null pointer exception.

I started using ERXCopyable and like it very much.  In one of my EO’s I have a special to-many relationship where the objects in it have to be copied over in a specific order.   Therefore, I specified the Nullify copy type for that to-many.  That sets the to-many to null.  I then wrote the custom logic to copy the objects in the to-many in the correct order.  However, I encountered a null pointer exception because the to-many is null and the code written it assumes that the to-many starts out with an empty array.

It’s no big deal as I can work around it.  However, it made me think that maybe the Nullify copy type should leave to-many relationships alone instead of setting them to null.  Something like this:

…
case NULLIFY:
// Null out the to-one and leave to-many as is so that it remains as an empty array
if (relationship.isToMany() == false) {
destination.takeStoredValueForKey(null, relationshipName);
}
break;
…

Let me know what you think.

Thanks,
Ricardo Parada


 _______________________________________________
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

  • Follow-Ups:
    • Re: ERXCopyable's Nullify in modelCopyRelationship()
      • From: Chuck Hill <email@hidden>
  • Prev by Date: Re: Starting second instance=app not available
  • Next by Date: Re: ERXCopyable's Nullify in modelCopyRelationship()
  • Previous by thread: Re: Starting second instance=app not available
  • Next by thread: Re: ERXCopyable's Nullify in modelCopyRelationship()
  • Index(es):
    • Date
    • Thread