• 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: ObjectNotAvailableException vs NSKeyValueCoding$Null
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ObjectNotAvailableException vs NSKeyValueCoding$Null


  • Subject: Re: ObjectNotAvailableException vs NSKeyValueCoding$Null
  • From: Calven Eggert <email@hidden>
  • Date: Tue, 17 Mar 2015 08:37:18 -0400

Chuck,

I was told by one of my college professor's, 30 years ago, that 80% of the time the problem is with the data and as you have pointed out, there was a problem with the data.  In my test database there was an invalid value (I just checked prod and all is ok there, whew) and so I fixed that and the problem went away.  Thanks for your suggestion.  Regardless, it's good to know how to handle this situation in WOnder.

Calven


On 2015-03-16, at 5:09 PM, Chuck Hill wrote:

Hi Calven,

ERXDatabaseContextDelegate.databaseContextFailedToFetchObject will explain what you are seeing.  You can see the property er.extensions.ERXDatabaseContextDelegate.tolerantEntityPattern to avoid this behaviour but… The best thing to do here is to ensure that your database has referential integrity.  :-)    The FK should be null not zero so that the first line will return pgEO == null which you should then check before the second line to avoid the dreaded NPE.  You code is relying on the behaviour of a “dummy fault EO”: http://lists.apple.com/archives/webobjects-dev/2008/Sep/msg00208.html


Chuck


On 2015-03-16, 1:22 PM, "Calven Eggert" wrote:

In moving a project over to Project Wonder, I'm happy to say that things are going very smoothly.  Today I've come across an issue with this code:

EOEnterpriseObject pgEO = (EOEnterpriseObject) currentTrial.valueForKey("programGrouping");
        String programGroupingStr = (String) pgEO.valueForKeyPath("displayName");
return programGroupingStr;

Previously when pgEO did not exist, (a valid result)  the code would continue to run and I'd simply get null in programGroupingStr. The value for the pgEO after line one is this:

{values = {programGroupingId = <com.webobjects.foundation.NSKeyValueCoding$Null>; displayName = <com.webobjects.foundation.NSKeyValueCoding$Null>; bixidentity = "null"; }; this = "<com.webobjects.eocontrol.EOGenericRecord 7e6bc5aa _EOIntegralKeyGlobalID[BIXProgramGrouping (java.lang.Integer)0]>"; }


Now using Project Wonder, the value of pgEO becomes:
<er.extensions.eof.ERXGenericRecord pk:"0">

and when trying to execute the second line:
ObjectNotAvailableException: No er.extensions.eof.ERXGenericRecord found with globalID: <BIXProgramGrouping: [programGroupingId: '0']

What is the best way to deal with this scenario?

Calven



_______________________________________________
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: 
 >ObjectNotAvailableException vs NSKeyValueCoding$Null (From: Calven Eggert <email@hidden>)
 >Re: ObjectNotAvailableException vs NSKeyValueCoding$Null (From: Chuck Hill <email@hidden>)

  • Prev by Date: Re: Values in URL for WOCheckBox?
  • Next by Date: Help on Ponder
  • Previous by thread: Re: ObjectNotAvailableException vs NSKeyValueCoding$Null
  • Next by thread: Help on Ponder
  • Index(es):
    • Date
    • Thread